10070 - Leap Year or Not Leap Year and ...

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

10070 - Leap Year or Not Leap Year and...

Post by helloneo »

Code: Select all

code removed
i got WA..
any advice..?
Last edited by helloneo on Fri Jun 08, 2007 6:36 am, edited 2 times in total.

chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 »

If you have searched through this forum, you would have found the solution to your problem. The input does not fit into an int, nor long nor long long. You have to use strings.

Search through this forum for 10070 for past threads to this problem. Hope this helps.

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

to helloneo:
your author id seems to be very familiar..
... oh! wait a sec. It's my uva ID.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

thanks..
then i really have to study BIG INTEGER.. ^^

and what a coincidence.. sohel.. ~

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

sohel wrote:to helloneo:
your author id seems to be very familiar..
... oh! wait a sec. It's my uva ID.
Sohel, how is it your uva ID :-?

mmij
New poster
Posts: 10
Joined: Mon Jul 11, 2005 7:13 am
Location: PlanetEarth

10070 again!!

Post by mmij »

hi,
i've read all topics about 10070 and all sample matches with my output....
but still WA?? plz plz plz anybody findout bug in my code or give me some critical input.
tanx

Code: Select all

//got acc :lol: 
Last edited by mmij on Fri Oct 14, 2005 7:58 am, edited 1 time in total.

tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Re: 10070 again!!

Post by tan_Yui »

Hi, mmij.
Although your algorithm is correct, there is incorrect part caused by careless mistake.

Check the word 'festival' in your code.
After fixed, you'll get Accepted in nice CPU Time. :)

Best regards.

mmij
New poster
Posts: 10
Joined: Mon Jul 11, 2005 7:13 am
Location: PlanetEarth

Post by mmij »

thanks tan.
next time i should be careful with spelling :roll:

Munni
New poster
Posts: 9
Joined: Tue Jan 03, 2006 4:59 pm

10070 WA

Post by Munni »

Can anuone give me some critical I/O. I can't fix the bug o my code.plz help me.


/*My code */

#include<stdio.h>
#include<iostream.h>
#include<string.h>
#include<math.h>
int checkleap(char year[])
{

int len,check1=0,check2=0,i,j;
long int sum1=0,sum2=0;
len=strlen(year);
if(year[len-2]=='0'&&year[len-1]=='0')
check1=1;
for(i=0,j=len-1;i<2;i++,j--)
sum1+=(year[j]-48)*pow(10,i);

if(sum1%4==0)
check2=1;
if(!check1&&check2)
return 1;
for(i=0,j=len-3;i<2;j--,i++)
sum2+=(year[j]-48)*pow(10,i);

if(check1&&((sum2%4)==0))
return 1;
else
return 0;


}
int checkbul(char year[])
{


int len,check1=0,check2=0,i,j;
long int sum1=0,sum2=0;
len=strlen(year);
if(year[len-1]=='0'||year[len-1]=='5')
check1=1;
if((len%2)==0)
{
for(i=0;i<=len-2;i=i+2)
sum1+= year-48;

for(j=1;j<=len-1;j=j+2)
sum2+= year[j]-48;
}
else
{
for(i=0;i<=len-1;i=i+2)
sum1+= year-48;

for(j=1;j<=len-2;j=j+2)
sum2+= year[j]-48;

}

if(((sum1-sum2)%11)==0)
check2=1;

if(check1&&check2)
return 1;
else
return 0;






}





int checkhul(char year[])

{

int len,check1=0,check2=0,i;
long int sum1=0;
len=strlen(year);

if(year[len-1]=='0'||year[len-1]=='5')
check1=1;


for(i=0;i<len;i++)
sum1+=year-48;
if((sum1%3)==0)

check2=1;


if(check1&&check2)
return 1;
else
return 0;



}


int main(void)
{
char year[50000];
int l,h,b=0,count=0;
while(gets(year))
{
if(count)
cout<<"\n";
l=checkleap(year);
h=checkhul(year);

if(l)
{
cout<<"This is leap year.\n";
b=checkbul(year);
if(b)
cout<<"This is buluculu festival year.\n";
b=0;

}

if(h)
cout<<"This is huluculu festival year.\n";

if(!l&&!h&&!b)
cout<<"This is an ordinary year.\n";
count++;

}



return 0;






}

Solaris
Learning poster
Posts: 99
Joined: Sun Apr 06, 2003 5:53 am
Location: Dhaka, Bangladesh
Contact:

Post by Solaris »

check the spelling "buluculu".. :wink:

It took me 1 hour to find this bug in my own code :P
Where's the "Any" key?

Munni
New poster
Posts: 9
Joined: Tue Jan 03, 2006 4:59 pm

Post by Munni »

Many many thnks to u.There was another prblmin my code.At last fix it nd got AC.Thnks again.

tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

10070 WA

Post by tmdrbs6584 »

#include<iostream.h>
int main(){
long long int a;
while(cin >> a){
if(a%4==0){
if(a%400==0){
cout << "This is leap year." << endl;
}
else if(a%100==0)
cout << "This is an ordinary year." << endl;
else{
cout << "This is leap year." << endl;
}
}
else
cout << "This is an ordinary year." << endl;
if(a%15==0){
cout << "This is huluculu festival year." << endl;
}
if(a%4==0){
if(a%400==0){
if(a%55==0)
cout << "This is bulukulu festival year." << endl;
}
else if(a%100==0){}
else{
if(a%55==0)
cout << "This is bulukulu festival year." << endl;
}
}
cout << endl;
}
return 0;
}
Why WA?

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

input is very very large.. doesn't even fit in 64 bit integer..

tot
New poster
Posts: 1
Joined: Sun Jan 29, 2006 10:41 am

10070 WA Help........

Post by tot »

Ye,I've just got it~Thanks!
^_^

tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

&#47336;&#47336;&#47336;

Post by tmdrbs6584 »

왜 올렸는지
ㅡ,.ㅡ;;

Post Reply

Return to “Volume 100 (10000-10099)”