Re: UVA 10070
Posted: Wed Jun 11, 2014 11:04 pm
brianfry713 wrote:The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.
The Online Judge board
https://onlinejudge.org/board/
brianfry713 wrote:The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.
Code: Select all
#include<stdio.h>
int main()
{
freopen("10070.txt", "r", stdin);
long long int lp,h,b,yr;
while(scanf("%lld",&yr)!=EOF)
{
lp=h=b=0;
if((yr%4==0 && yr%100!=0) || yr%400==0)
lp=1;
if(yr%15==0)
h=1;
if(lp==1 && yr%55==0)
b=1;
if(lp==1)
printf("This is leap year.\n");
if(h==1)
printf("This is huluculu festival year.\n");
if(b==1)
printf("This is bulukulu festival year.\n");
if(lp==0 && h==0 && b==0)
printf("This is an ordinary year.\n");
printf("\n");
}
return 0;
}
If you have problems read that posts.brianfry713 wrote:The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.
Code: Select all
#include <stdio.h>
#include <string.h>
int div_4(char a[])
{
int i,remainder = 0;
for(i=0;a[i]!=0;i++)
{
remainder = (remainder*10 + a[i]-48)%4;
}
if(remainder == 0)
return 1;
else
return 0;
}
int div_15(char a[])
{
int i,remainder = 0;
for(i=0;a[i]!=0;i++)
{
remainder = (remainder*10 + a[i]-48)%15;
}
if(remainder == 0)
return 1;
else
return 0;
}
int div_55(char a[])
{
int i,remainder = 0;
for(i=0;a[i]!=0;i++)
{
remainder = (remainder*10 + a[i]-48)%55;
}
if(remainder == 0)
return 1;
else
return 0;
}
int div_100(char a[])
{
int i,remainder = 0;
for(i=0;a[i]!=0;i++)
{
remainder = (remainder*10 + a[i]-48)%100;
}
if(remainder == 0)
return 1;
else
return 0;
}
int div_400(char a[])
{
int i,remainder = 0;
for(i=0;a[i]!=0;i++)
{
remainder = (remainder*10 + a[i]-48)%400;
}
if(remainder == 0)
return 1;
else
return 0;
}
int main()
{
char a[1000000];
int b4,b15,b55,b100,b400;
int flag,leap;
int start = 0;
while(gets(a)!=NULL)
{
leap = flag = 0;
if(start != 0)
printf("\n");
b4 = div_4(a);
b15 = div_15(a);
b55 = div_55(a);
b100 = div_100(a);
b400 = div_400(a);
if((b4==1&&b100!=0)||(b400))
{
printf("This is leap year.\n");
leap = 1;
flag = 1;
}
if(b15)
{
printf("This is huluculu festival year.\n");
flag = 1;
}
if(b55)
{
if(leap == 1)
printf("This is bulukulu festival year.\n");
}
if(flag != 1)
printf("This is an ordinary year.\n");
start = 1;
}
return 0;
}
osan wrote:please check this input & output. i hope these will help u.
INPUTOUTPUT2200
3000
6000
2000
10500
5500& one thing ur code is giving a extra blank line after last output. be careful about this.This is an ordinary year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is an ordinary year.
Code: Select all
Thanks! Code removed after AC
Don't forget to remove your code after getting accepted.alu_mathics wrote:try with thisOutput:456464484515645448647512343674234567564234564784234564754742345647424500
838286831260478655
838286831260478655If you can pass this input , hope your code will get A.C.This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
Code: Select all
Thanks! Code removed after AC
Don't print blank line after last case.A blank line should separate the output for each line of input
Code: Select all
GOT AC
Code: Select all
#include <iostream>
..
int ok = 0;
char ch;
while(std::cin.getline(num, 10000)) // gets(num) also works
{
..
if (ok++) puts("");
if(a==1)
..
else if(a==0&&c==0)
printf("This is an ordinary year.\n");
}