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
SHAHADAT
New poster
Posts: 23
Joined: Thu Jun 22, 2006 8:55 am
Location: sust,bangladesh

10070 why wa.Please give critical input, output

Post by SHAHADAT »

Hi,
I have got wa 10070.Please give me critical input output.
ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post by ayon »

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.
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

bigNum is not necessery,
There is number theory.
ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post by ayon »

emotional blind wrote:bigNum is not necessery,
There is number theory.
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 long
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
SHAHADAT
New poster
Posts: 23
Joined: Thu Jun 22, 2006 8:55 am
Location: sust,bangladesh

Post by SHAHADAT »

Thanks a lot all of you.
I got it accepted....................

-----------------------------------------------------------------
Programming is nothing but self examining.
deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Location: Bangladesh
Contact:

10070,WA & WA &....!!!

Post by deena sultana »

hi,
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA. :roll:
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;

		}
	

	
I need ur help.
deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Location: Bangladesh
Contact:

10070,WA & WA &....!!!

Post by deena sultana »

hi,
i m getting wa in the 10070 for several times. i did some corrections bt still it is WA. :roll:
Any1 there 2 help me, plz?

here is my code:

Code: Select all

	removed

	
I need ur help.
Last edited by deena sultana on Fri Jun 30, 2006 10:09 pm, edited 1 time in total.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

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.. :wink:
deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Location: Bangladesh
Contact:

Still WA

Post by deena sultana »

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:

Code: Select all

	removed after AC

	
plz help, plzzzzzzzzzz.
Last edited by deena sultana on Fri Jun 30, 2006 10:07 pm, edited 1 time in total.
deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Location: Bangladesh
Contact:

Post by deena sultana »

Sohel,

u r really gr8.
i m thanking u 4m my heart.

i get AC at last . thank u so much. :D
pankaj trivedi
New poster
Posts: 11
Joined: Wed Jun 21, 2006 5:11 pm
Contact:

WA

Post by pankaj trivedi »

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;

}

}
vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita »

what's the error why WR :(

Code: Select all

CODE REMOVED AFTER
AC
help me out.................[/b][/b]
Last edited by vinit_iiita on Thu Jul 13, 2006 2:29 pm, edited 1 time in total.
win
ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post by ayon »

buluculu or bulukulu ???
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

Post by vinit_iiita »

thanks a lot..... i got accepted. this is my way of making damn sily mistakes..
win
898989
Learning poster
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt
Contact:

10070 Why wa.

Post by 898989 »

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
Post Reply

Return to “Volume 100 (10000-10099)”