10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
Re: Getting WA - UVA 10070 -Leap Year or Not Leap Year and …
Got AC...
thank you brianfry713...
thank you brianfry713...
UVA 10070
whats wrong??
#include<stdio.h>
#include<string.h>
int main()
{
char a[100000];
int i,y4,y15,y55,y100,y400;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;
for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}
printf("\n");
if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}
#include<stdio.h>
#include<string.h>
int main()
{
char a[100000];
int i,y4,y15,y55,y100,y400;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;
for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}
printf("\n");
if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
My AC code assumes a line can be 1000000 digits long.
Check input and AC output for thousands of problems on uDebug!
Re: UVA 10070
Ok char a[1000000];
But still wrong answer brianfry713.
But still wrong answer brianfry713.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
Don't print a blank line at the start of the output.
Check input and AC output for thousands of problems on uDebug!
Re: UVA 10070
Still wrong Answer brianfry713....
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
Post your updated code.
Check input and AC output for thousands of problems on uDebug!
Re: UVA 10070
#include<stdio.h>
#include<string.h>
int main()
{
char a[1000000];
int i,y4,y15,y55,y100,y400,j=0;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;
if(j!=0)
printf("\n");
j=1;
for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}
if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}
#include<string.h>
int main()
{
char a[1000000];
int i,y4,y15,y55,y100,y400,j=0;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;
if(j!=0)
printf("\n");
j=1;
for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}
if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
Try input: 16555 output should be: This is an ordinary year.
Check input and AC output for thousands of problems on uDebug!
Re: UVA 10070
try 22055
This is an ordinary year.
This is an ordinary year.
Re: 10070 - Leap Year or Not Leap Year and ...
what's the problem with my code?
code deleted.
plz help.
code deleted.
plz help.
Last edited by hoimo on Tue Jan 07, 2014 10:46 pm, edited 1 time in total.
Re: UVA 10070
My code gives right answer for every input given here.
but still WA.
Plz help. thanx in advance.
but still WA.
Plz help. thanx in advance.
Re: UVA 10070
here is my code.
Code: Select all
#include<stdio.h>
#include<string.h>
char yearch[100000000];
int yearint[100000000];
int main()
{
int hulu, bulu, flg, line=0, add, temp, diff;
int d3, d4, d5, d11, d55;
int i, len, frst, lst, lstp;
while( scanf("%s",yearch) != EOF )
{
d5=1;
hulu=bulu=flg=0;
if(line)
printf("\n");
line=1;
len = strlen(yearch);
lstp=len-1;
lst=frst=0;
for( i=len-1;i>=0;i-- )
{
yearint[i]=yearch[i]-'0';
if( i==lstp ) {
lst=lst+yearint[i];
lstp=lstp-2;
}
else {
frst=frst+yearint[i];
}
}
add = frst+lst;
diff = lst-frst;
d3=add%3;
temp = yearint[len-1]+yearint[len-2]*10;
d4 = temp%4;
if( yearint[len-1]==0 || yearint[len-1]==5 )
d5=0;
d11 = diff%11;
if( d3==0 && d5==0 ) hulu=1;
if( d5==0 && d11==0 ) d55=0;
else d55=1;
if( yearint[len-1]=='0' && yearint[len-2]=='0' ) {
if( d4 == 0 ) {
flg++;
printf( "This is leap year.\n" );
if( d55==0 )
bulu=1;
}
}
else {
if( d4==0 ) {
flg++;
printf( "This is leap year.\n" );
if( d55==0 )
bulu=1;
}
}
if( hulu==1 ) {
flg++;
printf( "This is huluculu festival year.\n" );
}
if( bulu==1 ) {
flg++;
printf( "This is bulukulu festival year.\n" );
}
if( flg==0 )
printf("This is an ordinary year.\n");
}
}
-
- 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 ...
You're printing extra blank lines.
Check input and AC output for thousands of problems on uDebug!