10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10070 why wa?
Don't print a blank line at the end of the output.
Check input and AC output for thousands of problems on uDebug!
Re: 10070 why wa?
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()
{
long long a,s,d,f,g,h,j,k,l,e,E,q,c3,c11,Q,kk,w,ww,qq,ee,rr,tt,yy,iii,iiii,iiiii,uu,u;
string aa;
while(cin>>aa)
{
int leap=0,bulu=0,hulu=0;
a=aa.size();
if(a<5)
{
qq=5-a;
for(ww=0;ww<=qq;ww++)
{
aa="0"+aa;
}
}
a=aa.size();
ee=0;rr=0;
int oo=1;
for(tt=a-1;;tt--)
{
yy=(int)(aa[tt]-'0');
ee=ee+yy*oo;
rr++;
oo=oo*10;
if(rr==4) break;
}
e=0;E=0;
for(q=a-1;q>=0;q=q-2)
{
char l=aa[q];
e=e+(int)(l-'0');
}
for(Q=a-2;Q>=0;Q=Q-2)
{
char L=aa[Q];
E=E+(int)(L-'0');
}
k=ee;
if((k%4==0 && k%100!=0) || (k%400==0))
{
leap=1;
}
c3=e+E;
c11=e-E;
s=(int)(aa[a-1]-'0');
if((s==5 || s==0) && (c3%3==0))
{
hulu=1;
}
if(leap==1)
{
if((s==5 || s==0) && ((c11%11)==0))
{
bulu=1;
}
}
if(leap==1) printf("This is leap year.\n");
if(hulu==1) printf("This is huluculu festival year.\n");
if(bulu==1) printf("This is bulukulu festival year.\n");
if(leap==0 && hulu==0 && bulu==0) printf("This is an ordinary year.\n");
}
return 0;
}
what should this problem be called.
disappointing or embarrassing
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()
{
long long a,s,d,f,g,h,j,k,l,e,E,q,c3,c11,Q,kk,w,ww,qq,ee,rr,tt,yy,iii,iiii,iiiii,uu,u;
string aa;
while(cin>>aa)
{
int leap=0,bulu=0,hulu=0;
a=aa.size();
if(a<5)
{
qq=5-a;
for(ww=0;ww<=qq;ww++)
{
aa="0"+aa;
}
}
a=aa.size();
ee=0;rr=0;
int oo=1;
for(tt=a-1;;tt--)
{
yy=(int)(aa[tt]-'0');
ee=ee+yy*oo;
rr++;
oo=oo*10;
if(rr==4) break;
}
e=0;E=0;
for(q=a-1;q>=0;q=q-2)
{
char l=aa[q];
e=e+(int)(l-'0');
}
for(Q=a-2;Q>=0;Q=Q-2)
{
char L=aa[Q];
E=E+(int)(L-'0');
}
k=ee;
if((k%4==0 && k%100!=0) || (k%400==0))
{
leap=1;
}
c3=e+E;
c11=e-E;
s=(int)(aa[a-1]-'0');
if((s==5 || s==0) && (c3%3==0))
{
hulu=1;
}
if(leap==1)
{
if((s==5 || s==0) && ((c11%11)==0))
{
bulu=1;
}
}
if(leap==1) printf("This is leap year.\n");
if(hulu==1) printf("This is huluculu festival year.\n");
if(bulu==1) printf("This is bulukulu festival year.\n");
if(leap==0 && hulu==0 && bulu==0) printf("This is an ordinary year.\n");
}
return 0;
}
what should this problem be called.
disappointing or embarrassing

Re: 10070 why wa?
Print blank line between two cases.
like this
Input:
Output:
But your output:
Do not forget, remove your code after accept.
like this
Input:
Code: Select all
330000
330000
Code: Select all
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
Code: Select all
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
"Learning to love yourself is the greatest love of all" - Michael Masser and Linda Creed
Re: 10070 - Leap Year or Not Leap Year and …
removed AC code.
Last edited by gr81 on Sat Oct 27, 2012 12:38 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10070 - Leap Year or Not Leap Year and …
Try getting rid of these lines:
Code: Select all
if (atoi(lstr.c_str()) < 2000)
continue;
Check input and AC output for thousands of problems on uDebug!
Re: 10070 - Leap Year or Not Leap Year and …
i resubmitted the code after removing the following lines....still WA ?
any more suggestion where i can look...
any more suggestion where i can look...
Re: 10070 - Leap Year or Not Leap Year and …
it is bulukulu not buluculu....
thanks..
thanks..
-
- New poster
- Posts: 5
- Joined: Fri Nov 09, 2012 11:33 pm
Re: 10070 - Leap Year or Not Leap Year and …
Code: Select all
Accepted
:D
Last edited by mahbub2012 on Tue Dec 11, 2012 12:12 am, edited 2 times in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10070 - Leap Year or Not Leap Year and …
Don't print an extra blank line at the end of the output.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 5
- Joined: Fri Nov 09, 2012 11:33 pm
Re: 10070 - Leap Year or Not Leap Year and …
Thank you brianfry713.

Code: Select all
Accepted
Last edited by mahbub2012 on Tue Dec 11, 2012 12:13 am, edited 2 times in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10070 - Leap Year or Not Leap Year and …
A blank line should separate the output for each line of input.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 3
- Joined: Fri Mar 01, 2013 6:17 pm
Re: 10070 - Leap Year or Not Leap Year and …
My code does provide all the sample output. but where it is wrong. code is
Code: Select all
//accepted
Last edited by tamimcsedu19 on Thu Mar 21, 2013 6:50 pm, edited 1 time in total.
Re: 10070 - Leap Year or Not Leap Year and …
tamimcsedu19 wrote:My code does provide all the sample output. but where it is wrongCode: Select all
[/quote] Notice the following statement, from the [i]Output[/i] specification: "A blank line should separate the output for each line of input". Maybe it could have been expressed a little better, but you can see that it says that blank lines should be used to [i]separate[/i] the output from different cases. So, make sure you don't print a blank line after the last test case. But make sure you do print a newline (\n) at the end of each line, which you're not doing in the "bulukulu festival" case.
Re: 10070 - Leap Year or Not Leap Year and …
#include<stdio.h>
#include<string.h>
int main()
{
int c15,c55,c100,c400,c4,ct=1,l,r,t;
char arr[100000];
while(scanf("%s",arr)==1)
{
int i,k,q=0,rem=0,m=0,w;
i=strlen(arr);
for(k=0; k<i; k++)
{
rem=rem*10;
rem+=arr[k]-48;
rem=rem%55;
q=q*10;
q+=arr[k]-48;
q=q%4;
m=m+arr[k]-48;
}
if (rem==0)c55=1; else c55=0;
if (q==0)c4=1;else c4=0;
if(m%3==0&&(arr[i-1]=='5' || arr[i-1]=='0'))c15=1;else c15=0;
if(arr[i-1]=='0'&&arr[i-2]=='0')c100=1;else c100=0;
w=arr[i-3]*100+arr[i-2]*10+arr[i-1];
if(w%4==0 || 1==0)c400=1;else c400=0;
r=0;
if(ct!=1)printf("\n");
if(c4 && (!c100||c400)){r=1;printf("This is leap year.\n");}
if(c15)printf("This is huluculu festival year.\n");
if(r && c55)printf("This is bulukulu festival year.\n");
if(r==0 && c15==0)printf("This is an ordinary year.\n");
ct++;
}
return 0;
}
Why got WA......please help.....
#include<string.h>
int main()
{
int c15,c55,c100,c400,c4,ct=1,l,r,t;
char arr[100000];
while(scanf("%s",arr)==1)
{
int i,k,q=0,rem=0,m=0,w;
i=strlen(arr);
for(k=0; k<i; k++)
{
rem=rem*10;
rem+=arr[k]-48;
rem=rem%55;
q=q*10;
q+=arr[k]-48;
q=q%4;
m=m+arr[k]-48;
}
if (rem==0)c55=1; else c55=0;
if (q==0)c4=1;else c4=0;
if(m%3==0&&(arr[i-1]=='5' || arr[i-1]=='0'))c15=1;else c15=0;
if(arr[i-1]=='0'&&arr[i-2]=='0')c100=1;else c100=0;
w=arr[i-3]*100+arr[i-2]*10+arr[i-1];
if(w%4==0 || 1==0)c400=1;else c400=0;
r=0;
if(ct!=1)printf("\n");
if(c4 && (!c100||c400)){r=1;printf("This is leap year.\n");}
if(c15)printf("This is huluculu festival year.\n");
if(r && c55)printf("This is bulukulu festival year.\n");
if(r==0 && c15==0)printf("This is an ordinary year.\n");
ct++;
}
return 0;
}
Why got WA......please help.....