10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
10070 why wa.Please give critical input, output
Hi,
I have got wa 10070.Please give me critical input output.
I have got wa 10070.Please give me critical input output.
-
- Experienced poster
- Posts: 161
- Joined: Tue Oct 25, 2005 8:38 pm
- Location: buet, dhaka, bangladesh
didn't you read this topic?
http://online-judge.uva.es/board/viewto ... ight=10070
use "search" button, that'll help you, and for 10070 you must use bigNum.
http://online-judge.uva.es/board/viewto ... ight=10070
use "search" button, that'll help you, and for 10070 you must use bigNum.
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
----------------
the world is nothing but a good program, and we are all some instances of the program
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
-
- Experienced poster
- Posts: 161
- Joined: Tue Oct 25, 2005 8:38 pm
- Location: buet, dhaka, bangladesh
thats right, this problem can be solved using only number theory, i meant that the input year must be taken as bigNum, not as int or long longemotional blind wrote:bigNum is not necessery,
There is number theory.
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
----------------
the world is nothing but a good program, and we are all some instances of the program
-
- New poster
- Posts: 36
- Joined: Mon Jun 19, 2006 5:43 pm
- Location: Bangladesh
- Contact:
10070,WA & WA &....!!!
hi,
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA.
Any1 there 2 help me, pz?
here is my code:
I need ur help.
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA.

Any1 there 2 help me, pz?
here is my code:
Code: Select all
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main()
{
int flag,count,len,n1,n2,n3,n4,odd,even;
char num1[5],y[10001],num2[5];
while(gets(y))
{
len=strlen(y);
flag=count=0;
num1[0]=y[len-2];
num1[1]=y[len-1];
num1[2]='\0';
n1=atoi(num1);
num2[0]=y[len-4];
num2[1]=y[len-3];
num2[2]='\0';
n4=atoi(num2);
//cout<<"n1 "<<n1<<" ";
if(((y[len-1]=='0' && y[len-2]=='0') && n4%4==0) || ((y[len-1]!='0' && y[len-2]!='0')&& n1%4==0)){
{
cout<<"This is leap year."<<endl;
flag++;
count++;}}
n2=0;
for(int i=0;i<len;i++)
n2+=y[i]-'0';
//cout<<"n2 "<<n2<<" ";
if(n2%3==0 && (y[len-1]=='0' || y[len-1]=='5')){
cout<<"This is huluculu festival year."<<endl;
flag++;}
odd=even=0;
for(int i=0;i<len;i+=2)
odd+=y[i]-'0';
for(int i=1;i<len;i+=2)
even+=y[i]-'0';
n3=abs(odd-even);
// cout<<"n3 "<<n3<<" ";
if(count>0 && (n3==0 || n3==11) && (y[len-1]=='0' || y[len-1]=='5'))
{
cout<<"This is bulukulu festival year."<<endl;
flag++;
}
if(flag==0)
cout<<"This is an ordinary year."<<endl;
cout<<endl;
}
return 0;
}
-
- New poster
- Posts: 36
- Joined: Mon Jun 19, 2006 5:43 pm
- Location: Bangladesh
- Contact:
10070,WA & WA &....!!!
hi,
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA.
Any1 there 2 help me, plz?
here is my code:
I need ur help.
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA.

Any1 there 2 help me, plz?
here is my code:
Code: Select all
removed
Last edited by deena sultana on Fri Jun 30, 2006 10:09 pm, edited 1 time in total.
hello-
I don't think you are handling the leap year property correctly..
A line from the problem statement..
A year that is divisible by 4 and not divisible by 100 with the exception that years that are divisible by 400 are also leap year.
it means:
if( year % 400 == 0 ) leap_year;
else if( year % 100 == 0 ) not_leap_year;
else if( year % 4 == 0 ) leap_year;
else not_leap_year.
so, the year 2404 is a leap_year... but your code seems to think otherwise.
# And there are several other threads related to this topic. You should posted a reply on those, rather than opening a new thread..
Hope it helps..
I don't think you are handling the leap year property correctly..
A line from the problem statement..
A year that is divisible by 4 and not divisible by 100 with the exception that years that are divisible by 400 are also leap year.
it means:
if( year % 400 == 0 ) leap_year;
else if( year % 100 == 0 ) not_leap_year;
else if( year % 4 == 0 ) leap_year;
else not_leap_year.
so, the year 2404 is a leap_year... but your code seems to think otherwise.
# And there are several other threads related to this topic. You should posted a reply on those, rather than opening a new thread..

Hope it helps..

-
- New poster
- Posts: 36
- Joined: Mon Jun 19, 2006 5:43 pm
- Location: Bangladesh
- Contact:
Still WA
dear sohel,
thanks for ur help. i was very much cofused abt that line.
now i made a correction but still it's gettin WA.
sohel, thanks again.
i dont know what to do. Any1 help me again?
my correction copy is here:
plz help, plzzzzzzzzzz.
thanks for ur help. i was very much cofused abt that line.
now i made a correction but still it's gettin WA.
sohel, thanks again.
i dont know what to do. Any1 help me again?
my correction copy is here:
Code: Select all
removed after AC
Last edited by deena sultana on Fri Jun 30, 2006 10:07 pm, edited 1 time in total.
-
- New poster
- Posts: 36
- Joined: Mon Jun 19, 2006 5:43 pm
- Location: Bangladesh
- Contact:
-
- New poster
- Posts: 11
- Joined: Wed Jun 21, 2006 5:11 pm
- Contact:
WA
here is my code ..i m getting WA ...please help!! 
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
bool four(string s)
{ int n=s.length();
int a,b,c;
a=s[n-1]-'0';
b=s[n-2]-'0';
c=10*b+a;
if(c%4==0)
return true;
else
return false;
}
bool five(string s)
{
int n=s.length();
int a;
a=s[n-1]-'0';
if(a==5 || a==0)
return true;
else
return false;
}
bool hundred(string s)
{ int n=s.length();
int a,b,c;
a=s[n-1]-'0';
b=s[n-2]-'0';
if(a==0 && b==0)
return true;
else
return false;
}
bool eleven(string s)
{int n=s.length();
int a,b,c;
int sum1=0,sum2=0,sum=0;
for(int i=0;i<n;++i)
{ sum+=s-'0';}
for(int i=n-1;i>=0;i=i-2)
{ sum1=sum1+s-'0';}
sum2=sum-sum1;
if(abs(sum1-sum2) %11==0)
return true;
else
return false;
}
bool three(string s)
{int n=s.length();
int sum1=0,sum2=0,sum=0;
for(int i=0;i<n;++i)
{ sum+=s-'0';}
if(sum%3==0)
return true;
else
return false;
}
main()
{
string y;
while(cin>>y)
{bool flag=false;
bool check=false;
if(four(y)==true && hundred(y)==true)
{ cout<<"This is leap year."<<endl;
flag=true;
check=true;}
else if(four(y)==true && hundred(y)==false)
{cout<<"This is leap year."<<endl;
flag=true;
check=true;
}
if(five(y)==true && three(y)==true)
{ cout<<"This is huluculu festival year."<<endl;
check=true;}
if(flag==true && eleven(y)==true && five(y)==true)
{cout<<"This is bulukulu festival year."<<endl;
check=true;}
if(!check)
cout<<"This is an ordinary year."<<endl;
cout<<endl;
}
}

#include<iostream>
#include<cmath>
#include<string>
using namespace std;
bool four(string s)
{ int n=s.length();
int a,b,c;
a=s[n-1]-'0';
b=s[n-2]-'0';
c=10*b+a;
if(c%4==0)
return true;
else
return false;
}
bool five(string s)
{
int n=s.length();
int a;
a=s[n-1]-'0';
if(a==5 || a==0)
return true;
else
return false;
}
bool hundred(string s)
{ int n=s.length();
int a,b,c;
a=s[n-1]-'0';
b=s[n-2]-'0';
if(a==0 && b==0)
return true;
else
return false;
}
bool eleven(string s)
{int n=s.length();
int a,b,c;
int sum1=0,sum2=0,sum=0;
for(int i=0;i<n;++i)
{ sum+=s-'0';}
for(int i=n-1;i>=0;i=i-2)
{ sum1=sum1+s-'0';}
sum2=sum-sum1;
if(abs(sum1-sum2) %11==0)
return true;
else
return false;
}
bool three(string s)
{int n=s.length();
int sum1=0,sum2=0,sum=0;
for(int i=0;i<n;++i)
{ sum+=s-'0';}
if(sum%3==0)
return true;
else
return false;
}
main()
{
string y;
while(cin>>y)
{bool flag=false;
bool check=false;
if(four(y)==true && hundred(y)==true)
{ cout<<"This is leap year."<<endl;
flag=true;
check=true;}
else if(four(y)==true && hundred(y)==false)
{cout<<"This is leap year."<<endl;
flag=true;
check=true;
}
if(five(y)==true && three(y)==true)
{ cout<<"This is huluculu festival year."<<endl;
check=true;}
if(flag==true && eleven(y)==true && five(y)==true)
{cout<<"This is bulukulu festival year."<<endl;
check=true;}
if(!check)
cout<<"This is an ordinary year."<<endl;
cout<<endl;
}
}
-
- New poster
- Posts: 30
- Joined: Mon Jun 19, 2006 10:37 pm
- Contact:
what's the error why WR
help me out.................[/b][/b]

Code: Select all
CODE REMOVED AFTER
AC
Last edited by vinit_iiita on Thu Jul 13, 2006 2:29 pm, edited 1 time in total.
win
-
- New poster
- Posts: 30
- Joined: Mon Jun 19, 2006 10:37 pm
- Contact:
-
- Learning poster
- Posts: 83
- Joined: Wed Feb 01, 2006 12:59 pm
- Location: (Fci-cu) Egypt
- Contact:
10070 Why wa.
Code: Select all
Cut After AC
Last edited by 898989 on Thu Aug 10, 2006 11:27 am, edited 1 time in total.
Sleep enough after death, it is the time to work.
Mostafa Saad
Mostafa Saad