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
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

Has the Search feature of this board suddenly stopped working for you?

http://acm.uva.es/board/viewtopic.php?t=467&start=22
ruba
New poster
Posts: 2
Joined: Mon Nov 06, 2006 12:13 pm
Location: dhaka
Contact:

10070 & 10038 got WA!!!

Post by ruba »

Hi,
could anyone give me some critical INPUT for 10070 & 10038?
cos i could'nt figure out what's going wrong with my code!!

:roll:
Important!!!
joy
New poster
Posts: 48
Joined: Wed Oct 18, 2006 1:00 pm
Location: Dhaka, Bangladesh
Contact:

Post by joy »

for 10070:

try this input:

Code: Select all

200000000000000000000000000000
23456789765432222224444444444444444
11111111111111111144444444444441111111111111
155555555555000000000000000000000
30000000000000000000000000000044444444444444444400000000000
100000000000000000000000000000000000000000000000000004444444444
444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
for 10038:

input:

Code: Select all

1 1 
2 1 2 
2 3 1
2 -1 0
1 5
form kisui na ... class tai asol....
iF U hv d class u get the form....
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Re: 10070 & 10038 got WA!!!

Post by Jan »

ruba wrote:Hi,
could anyone give me some critical INPUT for 10070 & 10038?
cos i could'nt figure out what's going wrong with my code!!
First search your problem in the board. I have found almost 10 threads about problem 10070 and almost 12-15 threads about problem 10038. If you want some help then post in an existing thread. If there is no thread then create a new thread. And another important thing is that you are posting in a wrong volume.
Ami ekhono shopno dekhi...
HomePage
albet_januar
New poster
Posts: 35
Joined: Wed Apr 12, 2006 6:03 pm
Location: jakarta, indonesia
Contact:

Post by albet_januar »

do my code give a wrong output??

Code: Select all

#include <stdio.h>
#include <string.h>

char year[2001];

void check_leap(void)
{
	int i;
	int len;
	int carry[5];
	int bilangan[5];
	int counter = 0;
	int j;

	len = strlen(year);
	carry[0] = carry[1] = carry[2] = carry[3] = carry[4] = 0;
	for(i=0;i<len;i++)
	{
		for(j=0;j<5;j++)
		{
			bilangan[j] = carry[j] + year[i] - '0';
			switch(j)
			{
				case 0 :
				{
					carry[j] = bilangan[j] % 4;
					break;
				}
				case 1 :
				{
					carry[j] = bilangan[j] % 100;
					break;
				}
				case 2 :
				{
					carry[j] = bilangan[j] % 400;
					break;
				}
				case 3 :
				{
					carry[j] = bilangan[j] % 15;
					break;
				}
				case 4 :
				{
					carry[j] = bilangan[j] % 55;
					break;
				}

			}
			carry[j] = carry[j] * 10;
		}

	}

	if(!carry[0])
	{
		if(!carry[1]) counter = 0;
		if(!carry[2]) counter = 1;
		if(counter) printf("This is leap year.\n");
	}
	else counter = 0;

	if(!carry[3])
	{
		printf("This is huluculu festival year.\n");
		counter = 1;
	}

	if(!carry[4]&&counter)
	{
		printf("This is bulukulu festival year.\n");
		counter = 1;
	}
	if(counter==0) printf("This is an ordinary year.\n");

	printf("\n");

}

int main()
{
	
	while(scanf("%s", year)!=EOF)
	{
		check_leap();

	}

	return 0;
}
help me..
thx b4.. :D
ahah2002
New poster
Posts: 5
Joined: Mon Sep 18, 2006 4:09 pm

10070 P.E...strange problem...plz help!!!

Post by ahah2002 »

I don't know why I got P.E...

#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int n;
int p;
int l;
int lasttwo;
int beforetwo;
int odd;
int even;
int sum;
int last;
int i;


while (cin>>str){
n=0;
p=0;
sum=0;
lasttwo=0;
beforetwo=0;
last=0;
odd=0;
even=0;
l=str.length();
lasttwo= (str[l-1]-'0')+(str[l-2]-'0')*10;
beforetwo=(str[l-3]-'0')+(str[l-4]-'0')*10;
last=str[l-1]-'0';
for(i=0;i<l;i++){
sum+=str-'0';
if (i%2==1){
odd+=str-'0';
}
if (i%2==0){
even+=str-'0';
}
}


cout<<endl;
if ( lasttwo!=0 && lasttwo%4==0){
cout<<"This is leap year."<<endl;
n++;
}
if (lasttwo==0 && beforetwo%4==0){
cout<<"This is leap year."<<endl;
n++;}

if ((last==0 || last==5) && sum%3==0){
cout<<"This is huluculu festival year."<<endl;
p++;
}

if (n>0 && (last==0 || last==5) && (odd-even)%11==0){
cout<<"This is bulukulu festival year."<<endl;}

if (n==0 && p==0){
cout<<"This is an ordinary year."<<endl;}

cout<<endl;
}

return 0;
}
nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Post by nymo »

problem statement says:

Code: Select all

A blank line should separate the output for each line of input. 
This means that you are supposed to print blanks only between test cases and NOT after the last case.

and two more things ... USE code tag, otherwise, it is difficult to get the things right(at least indentation ...) and do NOT create a new thread if there is already one ... or more ;)
regards,
nymo
ahah2002
New poster
Posts: 5
Joined: Mon Sep 18, 2006 4:09 pm

Post by ahah2002 »

Mine got a P.E...I don't know why...plz help me~~~

#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int n;
int p;
int l;
int lasttwo;
int beforetwo;
int odd;
int even;
int sum;
int last;
int i;


while (cin>>str){
n=0;
p=0;
sum=0;
lasttwo=0;
beforetwo=0;
last=0;
odd=0;
even=0;
l=str.length();
lasttwo= (str[l-1]-'0')+(str[l-2]-'0')*10;
beforetwo=(str[l-3]-'0')+(str[l-4]-'0')*10;
last=str[l-1]-'0';
for(i=0;i<l;i++){
sum+=str-'0';
if (i%2==1){
odd+=str-'0';
}
if (i%2==0){
even+=str-'0';
}
}


cout<<endl;
if ( lasttwo!=0 && lasttwo%4==0){
cout<<"This is leap year."<<endl;
n++;
}
if (lasttwo==0 && beforetwo%4==0){
cout<<"This is leap year."<<endl;
n++;}

if ((last==0 || last==5) && sum%3==0){
cout<<"This is huluculu festival year."<<endl;
p++;
}

if (n>0 && (last==0 || last==5) && (odd-even)%11==0){
cout<<"This is bulukulu festival year."<<endl;}

if (n==0 && p==0){
cout<<"This is an ordinary year."<<endl;}

}

return 0;
}
rifayat samee_du
New poster
Posts: 9
Joined: Tue Jul 11, 2006 8:44 am
Location: Beside you........

10070 PE help

Post by rifayat samee_du »

MY CODE:


#include <stdio.h>
#include <string.h>


void main(void)
{ char year[1000000];
int i,leap,ord;
while (scanf("%s",&year)!=EOF)
{
int mod4,mod100,mod400,mod15,mod55;
mod4=mod100=mod400=mod15=mod55=0;
ord=1;leap=0;
printf("\n");
for (i=0;i<strlen(year);i++)
{
mod4=(mod4*10+year-'0')%4;
mod100=(mod100*10+year-'0')%100;
mod400=(mod400*10+year-'0')%400;
mod15=(mod15*10+year-'0')%15;
mod55=(mod55*10+year-'0')%55;
}
if ((!mod4 && mod100) || !mod400)
{
leap=1;
ord=0;
printf("This is leap year.\n");
}
if (!mod15)
{
ord=0;
printf("This is huluculu festival year.\n");
}
if (leap && !mod55)
{
ord=0;
printf("This is bulukulu festival year.\n");
}
if (ord)
printf("This is an ordinary year.\n");


}

}


PLZ HELP ME!!!!! :oops:
vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

Post by vijay03 »

Look at the problem statement - it says
A blank line should separate the output for each line of input
Your program merely prints a blank line before each output set. Change that to

Code: Select all


if(count)
printf("\n");

where count denotes no of output set. First output set will have count=0;
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

Hi samee
dont post full code for PE
just post your output part

And Remove your code after AC

Best of Luck
Akash chhoyar swopno
Dream to touch the sky
Oronno
New poster
Posts: 21
Joined: Sun Jul 09, 2006 1:42 pm
Location: Dhaka
Contact:

Why WA in 10070

Post by Oronno »

I have do this problem and test it for all possible output from forum. It work here.
But when, i submit this in ACM, it show wrong answer :( .
Why???
Can anyone help me?

Code: Select all

 Code removed after getting AC
Last edited by Oronno on Fri Feb 29, 2008 12:18 pm, edited 1 time in total.
I like programming but i am so lazy to do it...
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Re: Why WA in 10070

Post by Jan »

Oronno wrote:

Code: Select all

...
while(scanf("%s",years)==1)
{
year=0;
len=strlen(years);
year= 1000*years[len-4]-48*1000 + 100*years[len-3]-48*100 + 10*years[len-2] - 48*10 + years[len-1] -48;
...
}
What if your 'len' is smaller like 1 or 2, your code will try to access negative index [len-3]!!!
Ami ekhono shopno dekhi...
HomePage
Oronno
New poster
Posts: 21
Joined: Sun Jul 09, 2006 1:42 pm
Location: Dhaka
Contact:

Re:

Post by Oronno »

But in the problem, its said that-

[quote]All the years will not be less than 2000 (to avoid the earlier different rules for leap years). Please don
I like programming but i am so lazy to do it...
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Sorry for the previous post, I should have read the description again. However, I think your code is correct. Check the spelling please... :lol:
Ami ekhono shopno dekhi...
HomePage
Post Reply

Return to “Volume 100 (10000-10099)”