10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
10070 & 10038 got WA!!!
Hi,
could anyone give me some critical INPUT for 10070 & 10038?
cos i could'nt figure out what's going wrong with my code!!

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

Important!!!
for 10070:
try this input:
for 10038:
input:
try this input:
Code: Select all
200000000000000000000000000000
23456789765432222224444444444444444
11111111111111111144444444444441111111111111
155555555555000000000000000000000
30000000000000000000000000000044444444444444444400000000000
100000000000000000000000000000000000000000000000000004444444444
444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
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....
iF U hv d class u get the form....
Re: 10070 & 10038 got WA!!!
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.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!!
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 35
- Joined: Wed Apr 12, 2006 6:03 pm
- Location: jakarta, indonesia
- Contact:
do my code give a wrong output??
help me..
thx b4..
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;
}
thx b4..

10070 P.E...strange problem...plz help!!!
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;
}
#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;
}
problem statement says:
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
Code: Select all
A blank line should separate the output for each line of input.
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
nymo
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;
}
#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;
}
-
- New poster
- Posts: 9
- Joined: Tue Jul 11, 2006 8:44 am
- Location: Beside you........
10070 PE help
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!!!!!
#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!!!!!

Look at the problem statement - it says
where count denotes no of output set. First output set will have count=0;
Your program merely prints a blank line before each output set. Change that toA blank line should separate the output for each line of input
Code: Select all
if(count)
printf("\n");
-
- Learning poster
- Posts: 62
- Joined: Sun Jul 09, 2006 8:31 am
- Location: University of Dhaka
- Contact:
Why WA in 10070
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?
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...
Re: Why WA in 10070
What if your 'len' is smaller like 1 or 2, your code will try to access negative index [len-3]!!!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; ... }
Ami ekhono shopno dekhi...
HomePage
HomePage
Re:
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
[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...
Sorry for the previous post, I should have read the description again. However, I think your code is correct. Check the spelling please... 

Ami ekhono shopno dekhi...
HomePage
HomePage