Posted: Wed Mar 14, 2007 8:05 am
Ohh...I really do a silly mistake. Its only the spelling mistake of "bulukulu" >> "buluculu"!
Okk......thanks everyone for helping.
Okk......thanks everyone for helping.
The Online Judge board
https://uva.onlinejudge.org/board/
Code: Select all
#include<stdio.h>
#include<string.h>
main()
{
char year[10000];
long a,b,c,d,e,l,rest,flag,sum,flag4,flag11,ten;
long arr[5];
while((l=strlen(gets(year)))>0)
{
rest=0;
flag=0;
flag4=0;
flag11=0;
for(a=0;a<=l-1;a++)
{rest=rest*10+(year[a]-48);
rest=rest%11;
}
if(rest==0)
flag11=1;
if(l<4)
{rest=0;ten=1;
for(a=l-1;a>=0;a--)
{
rest=(year[a]-48)*ten+rest;
ten=ten*10;
}
arr[1]=year[l-1]-48;
if(rest%4==0)
if(rest%100!=0^rest%400==0)
flag4=1;
}
else
{
for(a=1;a<=4;a++)
{arr[a]=year[l-a]-48;}
if(arr[1]==0&&arr[2]==0)
{
if((arr[3]+arr[4]*10)%4==0)
flag4=1;
}
else
if((arr[1]+arr[2]*10)%4==0)
flag4=1;
}
if(flag4==1)
{printf("This is leap year.\n");flag=1;}
if(arr[1]==0^arr[1]==5)
{
sum=0;
for(a=0;a<=l-1;a++)
sum=sum+year[a]-48;
if(sum%3==0)
{printf("This is huluculu festival year.\n");flag=1;}
if(flag11==1)
{printf("This is buluculu festival year.\n");flag=1;}
}
if(flag==0)
printf("This an ordinary year.\n");
}
}
[code]
Code: Select all
# include <iostream>
# include <string>
using namespace std;
string str;
bool mod4(string str)
{
int l = str.size();
int no = (str[l-2]-'0')*10 + (str[l-1]-'0');
return (no%4==0);
}
bool mod100()
{
int l = str.size();
int no = (str[l-2]-'0')*10 + (str[l-1]-'0');
return (no==0);
}
bool mod400()
{
int l = str.size();
return ( mod100() && mod4(str.substr(0,l-2)));
}
bool mod3()
{
int sum = 0;
for(int i=0;str[i];i++)
sum+=(str[i]-'0');
return (sum%3==0);
}
bool mod5()
{
int l = str.size();
return (str[l-1]=='0'||str[l-1]=='5');
}
bool mod11()
{
int sum = 0,pow=1;
for(int i=0;str[i];i++,pow*=-1)
sum+=(pow*(str[i]-'0'));
return (sum%11==0);
}
bool mod15()
{
return (mod3() && mod5());
}
bool mod55()
{
return (mod5() && mod11());
}
int main()
{
int ca=1;
while(cin>>str)
{
if(ca!=1)
cout<<endl;
ca++;
bool l = false;
bool p = false;
if(mod400()||(mod4(str)&&!mod100()))
{
cout<<"This is leap year."<<endl;
l=true;
p=true;
}
if(mod15())
{
cout<<"This is huluculu festival year."<<endl;
p=true;
}
if(l&&mod55())
{
cout<<"This is bulukulu festival year."<<endl;
p=true;
}
if(!p)
cout<<"This is an ordinary year."<<endl;
}
return 0;
}
Code: Select all
#include<stdio.h>
#include<string.h>
#define max 10000
int main (void)
{ char a[max];
int i,sum1,sum2,p,q,r,s,e,f,g;
while(scanf("%s",&a)==1)
{ p=strlen(a)-1;
sum1=0;
sum2=0;
q=0;
r=0;
s=0;
e=0;
f=0;
g=0;
for(i=0;i<=p;i+=2)
{ sum1+=(a[i]-'0');
}
for(i=1;i<=p;i+=2)
{ sum2+=(a[i]-'0');
}
if(((a[p]-'0')+((a[p-1]-'0')*10))%4==0)
{ e=1;
}
if(a[p]=='0' || a[p-1]=='0')
{ f=1;
}
if(a[p]=='0' && a[p-1]=='0' && ((a[p-2]-'0')+((a[p-3]-'0')*10))%4==0)
{ g=1;
}
if((e==1 && f!=1)|| g==1)
{ printf("This is leap year.\n");
q=1;
}
if((a[p]=='5'||a[p]=='0') && ((sum1+sum2)%3==0))
{ printf("This is hulukulu festival year.\n");
r=1;
}
if((a[p]=='5'||a[p]=='0') && ((sum1-sum2)%11==0) && q==1)
{ printf("This is bulukulu festival year.\n");
s=1;
}
if(q==0 && r==0 && s==0)
{ printf("This is an ordinary year.\n");
}
printf("\n");
}
return 0;
}
Code: Select all
4248035245857302861304475122262852382232831183377907185400973044372526725256648804647567360
Code: Select all
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
Code: Select all
#include<stdio.h>
int main()
{
char a[100001];
int b,c,d,e,f,x,i,y,p,q;
while(gets(a))
{
b=c=d=e=f=p=q=x=0;
for(i=0;a[i];i++)
{
b=(b*10+a[i]-48)%4;
c=(c*10+a[i]-48)%100;
d=(d*10+a[i]-48)%400;
e=(e*10+a[i]-48)%15;
f=(f*10+a[i]-48)%55;
}
if(y==1)
printf("\n");
if((b==0&&c!=0)||d==0)
{
x=y=1;
printf("This is leap year.\n");
}
if(e==0)
{
y=p=1;
printf("This is huluculu festival year.\n");
}
if(x==1&&f==0)
{
y=q=1;
printf("This is bulukulu festival year.\n");
}
if(x==0&&p==0&&q==0)
{
y=1;
printf("This is an ordinary year.\n");
}
}
return 0;
}
problem wrote:[c]....
..............
...........
...............
my output
==========
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is huluculu festival year.
This is buluculu festival year.
This is huluculu festival year.
This is Leap year.
This is buluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is ordinary year.
--This is Leap year. //15 th is not match of actual output.
--This is buluculu festival year.
This is ordinary year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is Leap year.
This is ordinary year.
This is ordinary year.
This is huluculu festival year.
This is Leap year.
This is huluculu festival year.
This is ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
This is Leap year.
This is Leap year.
This is huluculu festival year.
This is huluculu festival year.
This is ordinary year.
but actual output is::
========================
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is an ordinary year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is huluculu festival year.
This is bulukulu festival year.
This is huluculu festival year.
This is leap year.
This is bulukulu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is an ordinary year.
==This is leap year. //NOT MATCH IN MY OUTPUT//
This is an ordinary year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is leap year.
This is an ordinary year.
This is an ordinary year.
This is huluculu festival year.
This is leap year.
This is huluculu festival year.
This is an ordinary year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
This is leap year.
This is leap year.
This is huluculu festival year.
This is huluculu festival year.
This is an ordinary year.
HELP ME PLZ.
[\c]