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

Honour_00
New poster
Posts: 4
Joined: Tue Jul 17, 2012 4:04 pm

10070 why wa?

Post by Honour_00 »

removed
Last edited by Honour_00 on Tue Jul 24, 2012 7:55 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10070 why wa?

Post by brianfry713 »

Don't print a blank line at the end of the output.
Check input and AC output for thousands of problems on uDebug!
Honour_00
New poster
Posts: 4
Joined: Tue Jul 17, 2012 4:04 pm

Re: 10070 why wa?

Post by Honour_00 »

#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 :(
outsbook
New poster
Posts: 26
Joined: Fri Oct 28, 2011 2:42 am

Re: 10070 why wa?

Post by outsbook »

Print blank line between two cases.

like this
Input:

Code: Select all

330000
330000
Output:

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.
But your output:

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.
Do not forget, remove your code after accept.
"Learning to love yourself is the greatest love of all" - Michael Masser and Linda Creed
gr81
New poster
Posts: 46
Joined: Wed Sep 26, 2012 7:52 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by gr81 »

removed AC code.
Last edited by gr81 on Sat Oct 27, 2012 12:38 pm, edited 1 time in total.
brianfry713
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 …

Post by brianfry713 »

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!
gr81
New poster
Posts: 46
Joined: Wed Sep 26, 2012 7:52 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by gr81 »

i resubmitted the code after removing the following lines....still WA ?
any more suggestion where i can look...
gr81
New poster
Posts: 46
Joined: Wed Sep 26, 2012 7:52 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by gr81 »

it is bulukulu not buluculu....

thanks..
mahbub2012
New poster
Posts: 5
Joined: Fri Nov 09, 2012 11:33 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by mahbub2012 »

Code: Select all

Accepted
 :D 
Last edited by mahbub2012 on Tue Dec 11, 2012 12:12 am, edited 2 times in total.
brianfry713
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 …

Post by brianfry713 »

Don't print an extra blank line at the end of the output.
Check input and AC output for thousands of problems on uDebug!
mahbub2012
New poster
Posts: 5
Joined: Fri Nov 09, 2012 11:33 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by mahbub2012 »

Thank you brianfry713. :D

Code: Select all

Accepted
Last edited by mahbub2012 on Tue Dec 11, 2012 12:13 am, edited 2 times in total.
brianfry713
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 …

Post by brianfry713 »

A blank line should separate the output for each line of input.
Check input and AC output for thousands of problems on uDebug!
tamimcsedu19
New poster
Posts: 3
Joined: Fri Mar 01, 2013 6:17 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by tamimcsedu19 »

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.
lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 10070 - Leap Year or Not Leap Year and …

Post by lbv »

tamimcsedu19 wrote:My code does provide all the sample output. but where it is wrong

Code: 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.
hello
New poster
Posts: 25
Joined: Sun Mar 10, 2013 7:29 pm

Re: 10070 - Leap Year or Not Leap Year and …

Post by hello »

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

Return to “Volume 100 (10000-10099)”