10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
Thanks!!
I got AC, but with PE.
What may be??
I output results this way:
[cpp]
if (bisiesto(numero))
{
cout << "This is leap year." << endl;
bis = true;
fiesta=true;
}
if (huluculu(numero))
{
cout << "This is huluculu festival year." << endl;
fiesta = true;
}
if (bis && bulukulu(numero))
{
cout << "This is bulukulu festival year." << endl;
fiesta = true;
}
if (!fiesta)
cout << "This is an ordinary year." << endl;
cout << endl;
[/cpp]
I've also tried to cout the second endl, only between each year results and not just after each, but I also got AC (PE).
I got AC, but with PE.
What may be??
I output results this way:
[cpp]
if (bisiesto(numero))
{
cout << "This is leap year." << endl;
bis = true;
fiesta=true;
}
if (huluculu(numero))
{
cout << "This is huluculu festival year." << endl;
fiesta = true;
}
if (bis && bulukulu(numero))
{
cout << "This is bulukulu festival year." << endl;
fiesta = true;
}
if (!fiesta)
cout << "This is an ordinary year." << endl;
cout << endl;
[/cpp]
I've also tried to cout the second endl, only between each year results and not just after each, but I also got AC (PE).
-
- Experienced poster
- Posts: 146
- Joined: Sat Apr 26, 2003 2:51 am
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
dserrano, I'm very certain that your P.E. is caused because of the extra blank line. Example:
Your output:
while the correct one is:
See, the extra blank line your program output in the last line? That's why you got P.E.
Hope it helps!!
[/code]
Your output:
Code: Select all
This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
<blank line>
Code: Select all
This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
Hope it helps!!
[/code]
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
dserrano, I'm very certain that your P.E. is caused because of the extra blank line. Example:
Your output:
while the correct one is:
See, the extra blank line your program output in the last line? That's why you got P.E.
Hope it helps!!
Your output:
Code: Select all
This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
<blank line>
Code: Select all
This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
Hope it helps!!
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.
10070 help me plz
i think its ok.but wa.plz check my code where problem arise and give me the solution.
[cpp]
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 1000
void main()
{
char t[max];
long int sum=0,sum1=0,sum2=0;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(i%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
l=(t[i-2]-48)*10+(t[i-1]-48);
if(l%4==0)
leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2==11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1&&check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}
[/cpp]
[cpp]
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 1000
void main()
{
char t[max];
long int sum=0,sum1=0,sum2=0;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(i%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
l=(t[i-2]-48)*10+(t[i-1]-48);
if(l%4==0)
leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2==11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1&&check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}
[/cpp]
[c]
this is big input problem.i use following rule.about all of the input
output is ok.but some input output is not match in actual input output.help me.
any number divisible by two if last digit is divisible by two.
any number divisible by 3 if sum of digits is divisible by 3.
any number divisible by 5 if last digit is 0 or 5.
any number divisible by 11 if sum of it's even digits and sum of it's
odd digits are equal.
ex: 692863963 is divisible by 11.
6 + 2 + 8 + 9 + 3 = 26
9 + 8 + 3 + 6 = 26
any number divisible by 4 if last two digit is divisible by 4.
my source code is
====================
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 30000
#include<stdlib.h>
void main()
{
//freopen("e:\\10070.in","r",stdin);
//freopen("e:\\a10070.out","w",stdout);
char t[max],c[max];
long int sum=0,sum1=0,sum2=0,len,year;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
len = strlen(t);
for(j=0,i=len-4; j<4; i++,j++)
c[j] = t ;
c[j] = '\0' ;
year = atoi(c);
if( (year%4==0 && year%100!=0) || year%400==0)
leap = 1;
i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(j%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
//l=(t[i-2]-48)*10+(t[i-1]-48);
//if(l%4==0)
//leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2%11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1||check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}
input:
=======
2000
3600
4515
2001
22000
22055
22220
330000
330015
330220
456464484515645448647512343674234567564234564784234564754742345647424564
456464484515645448647512343674234567564234564784234564754742345647424565
456464484515645448647512343674234567564234564784234564754742345647424566
456464484515645448647512343674234567564234564784234564754742345647424567
456464484515645448647512343674234567564234564784234564754742345647424568
456464484515645448647512343674234567564234564784234564754742345647424569
456464484515645448647512343674234567564234564784234564754742345647424560
456464484515645448647512343674234567564234564784234564754742345647424500
234324234245646448451564544864751234367423456756423456478423456475474234564742456
23423423
65678645656377386585675675675622789235723451275172892374016526347623483274237487123848912347891237489123561237612734612375617234672461237123567123465781465714657136475617856127651237845173657813465781263478561234787856781349658716345786134785617823651782367845123675647823563784657834657834657834657861347856134785634786578134657816347856178567182346578134657823465723456123761789035617856163417454
838286831260478655
838286831260478400
838286831260478650
838286831260478655
228623681252857800
228623681252857815
228623681252857830
228623681252857810
2000
3600
4515
2001
my output
==========
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is huluculu festival year.
This is buluculu festival year.
This is huluculu festival year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is ordinary year.
--This is Leap year. //15 th is not match of actual output.
--This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is huluculu festival year.
This is Leap year.
This is huluculu festival year.
This is ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
but actual output is::
========================
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
This is huluculu festival year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is an ordinary year.
==This is leap year. //NOT MATCH IN MY OUTPUT//
This is an ordinary year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is an ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
HELP ME PLZ.
[\c]
this is big input problem.i use following rule.about all of the input
output is ok.but some input output is not match in actual input output.help me.
any number divisible by two if last digit is divisible by two.
any number divisible by 3 if sum of digits is divisible by 3.
any number divisible by 5 if last digit is 0 or 5.
any number divisible by 11 if sum of it's even digits and sum of it's
odd digits are equal.
ex: 692863963 is divisible by 11.
6 + 2 + 8 + 9 + 3 = 26
9 + 8 + 3 + 6 = 26
any number divisible by 4 if last two digit is divisible by 4.
my source code is
====================
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 30000
#include<stdlib.h>
void main()
{
//freopen("e:\\10070.in","r",stdin);
//freopen("e:\\a10070.out","w",stdout);
char t[max],c[max];
long int sum=0,sum1=0,sum2=0,len,year;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
len = strlen(t);
for(j=0,i=len-4; j<4; i++,j++)
c[j] = t ;
c[j] = '\0' ;
year = atoi(c);
if( (year%4==0 && year%100!=0) || year%400==0)
leap = 1;
i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(j%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
//l=(t[i-2]-48)*10+(t[i-1]-48);
//if(l%4==0)
//leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2%11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1||check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}
input:
=======
2000
3600
4515
2001
22000
22055
22220
330000
330015
330220
456464484515645448647512343674234567564234564784234564754742345647424564
456464484515645448647512343674234567564234564784234564754742345647424565
456464484515645448647512343674234567564234564784234564754742345647424566
456464484515645448647512343674234567564234564784234564754742345647424567
456464484515645448647512343674234567564234564784234564754742345647424568
456464484515645448647512343674234567564234564784234564754742345647424569
456464484515645448647512343674234567564234564784234564754742345647424560
456464484515645448647512343674234567564234564784234564754742345647424500
234324234245646448451564544864751234367423456756423456478423456475474234564742456
23423423
65678645656377386585675675675622789235723451275172892374016526347623483274237487123848912347891237489123561237612734612375617234672461237123567123465781465714657136475617856127651237845173657813465781263478561234787856781349658716345786134785617823651782367845123675647823563784657834657834657834657861347856134785634786578134657816347856178567182346578134657823465723456123761789035617856163417454
838286831260478655
838286831260478400
838286831260478650
838286831260478655
228623681252857800
228623681252857815
228623681252857830
228623681252857810
2000
3600
4515
2001
my output
==========
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is huluculu festival year.
This is buluculu festival year.
This is huluculu festival year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is ordinary year.
--This is Leap year. //15 th is not match of actual output.
--This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is huluculu festival year.
This is Leap year.
This is huluculu festival year.
This is ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
but actual output is::
========================
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
This is huluculu festival year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is an ordinary year.
==This is leap year. //NOT MATCH IN MY OUTPUT//
This is an ordinary year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is an ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
HELP ME PLZ.
[\c]
check this input & output
please check this input & output. i hope these will help u.
INPUT
INPUT
OUTPUT2200
3000
6000
2000
10500
5500
& one thing ur code is giving a extra blank line after last output. be careful about this.This is an ordinary year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is an ordinary year.
this time WA
what next...............?
what next...............?
runtime error
hi,
i've just recently registered to this website and i tried to send in a program...#10070...the leap year, huluculu year and the bulukulu year one. however, when i sent it, it said 'Runtime Error (SIGXFSZ)'. what does this mean? and how do i fix it? everything seems to be working on my computer...and this error msg is not explained in the "how to interpret judge replies" section. plz help. thanx a lot.
i've just recently registered to this website and i tried to send in a program...#10070...the leap year, huluculu year and the bulukulu year one. however, when i sent it, it said 'Runtime Error (SIGXFSZ)'. what does this mean? and how do i fix it? everything seems to be working on my computer...and this error msg is not explained in the "how to interpret judge replies" section. plz help. thanx a lot.
10070
this program seems to be working fine on my computer but gives me runtime error when i submit. this is my code:
[code]#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
ifstream fin;
ofstream fout;
fin.open("myprog.in");
fout.open("myprog.out");
while (!fin.eof())
{
char y[10000];
bool l;
fin.getline(y,10000,'\n');
//fin.ignore(1,'\n');
int n=strlen(y),sum=0,i,sume=0,sumo=0;
bool sth=true;
short ld=static_cast<int>(y[n-1])-48,sd=static_cast<int>(y[n-2])-48,td=static_cast<int>(y[n-3])-48,fd=static_cast<int>(y[n-4])-48;
l=(((sd*10+ld)%4==0) && (sd!=0 || ld!=0)) || (((fd*10+td)%4==0) && (sd==0 && ld==0));
for (i=0;i<n;i++)
{
sum=sum+(static_cast<int>(y[i])-48);
if (i%2==0) sumo=sumo+(static_cast<int>(y[i])-48);
else sume=sume+(static_cast<int>(y[i])-48);
}
if (l) { sth=false; fout<<"This is leap year.\n"; }
if (sum%3==0 && (ld==0 || ld==5)) {sth=false; fout<<"This is huluculu festival year.\n"; }
if ((l) && ((ld==0 || ld==5) && sumo==sume)) {sth=false; fout<<"This is bulukulu festival year.\n"; }
if (sth) fout<<"This is an ordinary year.\n";
if (!fin.eof()) fout<<"\n";
}
fin.close();
fout.close();
}[/code]
it says RUNTIME ERROR SIGXFSZ. i couldn't find it's meaning anywhere on this site or forum. on google i found it meant file size limit exceeded but i can't see how that's happening in my case. any help would be really appreciated. i've submitted lots of times and i get the same error. thanx a lot.
[code]#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
ifstream fin;
ofstream fout;
fin.open("myprog.in");
fout.open("myprog.out");
while (!fin.eof())
{
char y[10000];
bool l;
fin.getline(y,10000,'\n');
//fin.ignore(1,'\n');
int n=strlen(y),sum=0,i,sume=0,sumo=0;
bool sth=true;
short ld=static_cast<int>(y[n-1])-48,sd=static_cast<int>(y[n-2])-48,td=static_cast<int>(y[n-3])-48,fd=static_cast<int>(y[n-4])-48;
l=(((sd*10+ld)%4==0) && (sd!=0 || ld!=0)) || (((fd*10+td)%4==0) && (sd==0 && ld==0));
for (i=0;i<n;i++)
{
sum=sum+(static_cast<int>(y[i])-48);
if (i%2==0) sumo=sumo+(static_cast<int>(y[i])-48);
else sume=sume+(static_cast<int>(y[i])-48);
}
if (l) { sth=false; fout<<"This is leap year.\n"; }
if (sum%3==0 && (ld==0 || ld==5)) {sth=false; fout<<"This is huluculu festival year.\n"; }
if ((l) && ((ld==0 || ld==5) && sumo==sume)) {sth=false; fout<<"This is bulukulu festival year.\n"; }
if (sth) fout<<"This is an ordinary year.\n";
if (!fin.eof()) fout<<"\n";
}
fin.close();
fout.close();
}[/code]
it says RUNTIME ERROR SIGXFSZ. i couldn't find it's meaning anywhere on this site or forum. on google i found it meant file size limit exceeded but i can't see how that's happening in my case. any help would be really appreciated. i've submitted lots of times and i get the same error. thanx a lot.
i think u have no need to find much.
as i i know they send u a email. if u didn't disable the option.
there they always tell disucss about the problem. if u dont get WA.
GOOD LUCK
there they always tell disucss about the problem. if u dont get WA.
GOOD LUCK
That's not true either. Think of 22000. The difference between the sum of the even and odd digits is 4 which is not divisible by 11. Does anyone have a good rule for determining if a number is divisible by 11?
EDIT: Sorry, that post is correct. A number is divisible by 11 if the difference between the sum of its even digits and the sum of its odd digits is divisible by 11. I misunderstood what was posted. In the case of 22000 the sum of the even digits is 2 and the sum of the odd digits is 2. The difference is 0 and 0 mod 11 is 0. Thus 22000 is divisible by 11. A nice explanation of many of these rules is here:
http://mathforum.org/k12/mathtips/ward2.html
My misunderstanding is because I thought of even digits as being any digits in the entire number that were even as opposed to digits in even-numbered positions in the entire number.
EDIT: Sorry, that post is correct. A number is divisible by 11 if the difference between the sum of its even digits and the sum of its odd digits is divisible by 11. I misunderstood what was posted. In the case of 22000 the sum of the even digits is 2 and the sum of the odd digits is 2. The difference is 0 and 0 mod 11 is 0. Thus 22000 is divisible by 11. A nice explanation of many of these rules is here:
http://mathforum.org/k12/mathtips/ward2.html
My misunderstanding is because I thought of even digits as being any digits in the entire number that were even as opposed to digits in even-numbered positions in the entire number.
Computer Science is no more about computers than Astronomy is about telescopes.
-- E. W. Dijkstra
-- E. W. Dijkstra