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

haaaz
New poster
Posts: 29
Joined: Sun Sep 08, 2002 8:02 am

Re: 10070 Output Limit Exceeded

Post by haaaz »

Meng-Hsuan Wu wrote:This is my source code for problem 10070. When I ran it on my computer, it worked well when I input a long number. But I got "Output Limit Exceeded" when I submit it. Can anyone help me?
[c]#include <stdio.h>
#include <string.h>
main()
{
char s[10000];
int y[10000];
//...
[/c]
Maybe 10000 elements are not enough?
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

10070 Leap year or not... what could be wrong

Post by shamim »

:roll: I have submitted the following code for judging

i realize that i have to use strings to take input and i have used a technique to find the divisibility of large numbers by smaller ones. yet i get WA. Could someone help me to spot the mistake.


Cut :D : :P :) :lol:
Last edited by shamim on Mon Apr 28, 2003 8:26 am, edited 1 time in total.
PdR
New poster
Posts: 24
Joined: Mon Dec 30, 2002 4:27 am

Re: 10070 Leap year or not... what could be wrong

Post by PdR »

[c]
if (leap)
{
printf ("This is leap year.\n");
if (isdiv (line, 11)) bulu = 1;
}
[/c]
Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year)
I supose this is your problem :wink:
tat tvam asi
New poster
Posts: 30
Joined: Sat Nov 30, 2002 1:04 pm

Post by tat tvam asi »

helo
... plus a small typo :
use the word "bulukulu" - as in the
prob. statement - not "buluculu" .
bye
soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:

Post by soyoja »

Dear haaz.
10000 elements array would be enough to store test data.
My program also use 10000 elements char array.
Finally, I got "Accepted". ^^
Almost Human
Learning poster
Posts: 93
Joined: Sun Jan 12, 2003 3:30 pm

10070 - Leap Year or Not Leap Year and ...

Post by Almost Human »

I need some suggestion here ...

Do I have to use very long number in this case ???
Can I just use int or long ???

please help!
shahriar_manzoor
System administrator & Problemsetter
Posts: 399
Joined: Sat Jan 12, 2002 2:00 am

Yes

Post by shahriar_manzoor »

Yes numbers are out of range of any conventional data types - integer, long, int64 or long long etc
titid_gede
Experienced poster
Posts: 187
Joined: Wed Dec 11, 2002 2:03 pm
Location: Mount Papandayan, Garut

Post by titid_gede »

you must use big integer, pak andoko. anyway i do not know how is the upper limit.
Kalo mau kaya, buat apa sekolah?
Almost Human
Learning poster
Posts: 93
Joined: Sun Jan 12, 2003 3:30 pm

Post by Almost Human »

Thanks everyone..

I still don't know the precise limit for this...

but I used my verylonginteger class and used 2000 for MAXDIGIT and got AC for that ...
awik_10
New poster
Posts: 14
Joined: Sun May 18, 2003 11:56 am

10070

Post by awik_10 »

what's wromg with my program :cry: ? would anyone tell me what's my wrong? this is my code :
[c]
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

int main()
{
char s[10000];
int y[10000];
int len,i,m4,m15,m55,l,h,b,a,cek;
while(scanf("%s",s)==1)
{
fflush(stdin);
len=strlen(s);
for(i=0;i<len;i++)
{
if(!isdigit(s)) exit(1);
}
if(len<3) continue;
if(len==4)
{
cek=0;
for(i=0;i<4;i++)
{
cek=cek*10+s-'0';
}
if(cek<2000) continue;
}
if(len==0||s[0]<48||s[0]>57)
break;
for(i=9999;i>=len;i--)
y=0;
for(i=len-1;i>=0;i--)
if(s[len-1-i]>=48&&s[len-1-i]<=57)
y=s[len-1-i]-48;
m4=(y[1]*10+y[0])%4;
m15=y[len-1];
for(i=len-2;i>=0;i--)
m15=(m15*10+y)%15;
m55=y[len-1];
for(i=len-2;i>=0;i--)
m55=(m55*10+y)%55;
l=h=b=0;
if(m4==0)
l=1;
if(m15==0)
h=1;
if(l==1&&m55==0)
b=1;
if(l==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(l+h+b==0)
printf("This is an ordinary year.\n");
printf("\n");
}
return 0;
}[/c]

thank you
best regards,
awik
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

Your code looks ok, but there are few unnecessary things,

for(i=0;i<len;i++)
{
if(!isdigit(s)) exit(1);
}

there is no need to make this test,

One thing u could try is creating a single function to test for divisibility.
awik_10
New poster
Posts: 14
Joined: Sun May 18, 2003 11:56 am

Post by awik_10 »

One thing u could try is creating a single function to test for divisibility.
what's that mean, can you explain me for more detail, please?
i've removed the unnecessary thing from my program, but i still don' t get the acc.
thank you,
awik
turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Awik, probably this problem gives us a number with very-long digits. Can somebody confirm this statement ???

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).
turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Sorry, I should check for previous posts before making comments ...

Yes, this problem involves big-integer ...

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).
dserrano
New poster
Posts: 7
Joined: Tue Sep 17, 2002 2:39 am

Post by dserrano »

[quote="10153EN"]I solved this problem by storing the year number (which can be very large) in an integer array. Then check this year with some number theory.

For example, if a numbe if divible by 3, then the sum of all of it's digits is ....[/quote]

Excellent idea!!
What's the rule for knowing if a number is divisible by 11?
Post Reply

Return to “Volume 100 (10000-10099)”