Page 3 of 16

Posted: Thu Sep 11, 2003 3:52 am
by UFP2161
Divisibility by 11: If A[] is the array of digits .. then if the sum A[0] - A[1] + A[2] - A[3] + A[4] .. is divisible by 11, then A is too

Posted: Sat Sep 13, 2003 2:29 am
by dserrano
Thanks!!
I got AC, but with PE.

What may be??
I output results this way:

[cpp]
if (bisiesto(numero))
{
cout << "This is leap year." << endl;
bis = true;
fiesta=true;
}

if (huluculu(numero))
{
cout << "This is huluculu festival year." << endl;
fiesta = true;
}

if (bis && bulukulu(numero))
{
cout << "This is bulukulu festival year." << endl;
fiesta = true;
}

if (!fiesta)
cout << "This is an ordinary year." << endl;
cout << endl;
[/cpp]

I've also tried to cout the second endl, only between each year results and not just after each, but I also got AC (PE).

Posted: Sat Sep 13, 2003 4:04 am
by Dmytro Chernysh
Can you post some input/output? I've tried to solve it for several times, but still WA...

Posted: Sun Sep 14, 2003 4:42 pm
by Joseph Kurniawan
dserrano, I'm very certain that your P.E. is caused because of the extra blank line. Example:
Your output:

Code: Select all

This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
<blank line>
while the correct one is:

Code: Select all

This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
See, the extra blank line your program output in the last line? That's why you got P.E.
Hope it helps!!
[/code]

Posted: Sun Sep 14, 2003 4:42 pm
by Joseph Kurniawan
dserrano, I'm very certain that your P.E. is caused because of the extra blank line. Example:
Your output:

Code: Select all

This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
<blank line>
while the correct one is:

Code: Select all

This is leap year.
<blank line>
This is leap year.
This is huluculu festival year.
<blank line>
This is huluculu festival year.
<blank line>
This is an ordinary year.
See, the extra blank line your program output in the last line? That's why you got P.E.
Hope it helps!!

10070 help me plz

Posted: Tue Nov 25, 2003 11:03 am
by problem
i think its ok.but wa.plz check my code where problem arise and give me the solution.



[cpp]
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 1000

void main()
{
char t[max];
long int sum=0,sum1=0,sum2=0;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(i%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
l=(t[i-2]-48)*10+(t[i-1]-48);
if(l%4==0)
leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2==11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1&&check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}
[/cpp]

Posted: Wed Dec 10, 2003 11:40 am
by problem
[c]
this is big input problem.i use following rule.about all of the input
output is ok.but some input output is not match in actual input output.help me.



any number divisible by two if last digit is divisible by two.
any number divisible by 3 if sum of digits is divisible by 3.
any number divisible by 5 if last digit is 0 or 5.
any number divisible by 11 if sum of it's even digits and sum of it's
odd digits are equal.
ex: 692863963 is divisible by 11.
6 + 2 + 8 + 9 + 3 = 26
9 + 8 + 3 + 6 = 26
any number divisible by 4 if last two digit is divisible by 4.

my source code is
====================

#include<stdio.h>
#include<math.h>
#include<string.h>
#define max 30000
#include<stdlib.h>

void main()
{
//freopen("e:\\10070.in","r",stdin);
//freopen("e:\\a10070.out","w",stdout);
char t[max],c[max];
long int sum=0,sum1=0,sum2=0,len,year;
long int leap=0,check=0,check1=0,check2=0,check3=0;
long int i,j,l;
while(gets(t))
{
len = strlen(t);
for(j=0,i=len-4; j<4; i++,j++)
c[j] = t ;
c[j] = '\0' ;
year = atoi(c);

if( (year%4==0 && year%100!=0) || year%400==0)
leap = 1;

i=strlen(t);
for(j=0;j<i;j++)
{
sum+=t[j]-48;
if(j%2==0)
sum1+=t[j]-48;
else
sum2+=t[j]-48;
}
//l=(t[i-2]-48)*10+(t[i-1]-48);
//if(l%4==0)
//leap=1;
if(t[i-1]=='0'||t[i-1]=='5')
check=1;
if(sum%3==0)
check1=1;
if(sum%5==0)
check2=1;
if(sum1%11==sum2%11)
check3=1;
if(leap==1)
{
printf("This is Leap year.\n");
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
if(check3==1||check2==1)
printf("This is buluculu festival year.\n");
}
else
{
if(check==1&&check1==1)
printf("This is huluculu festival year.\n");
else
printf("This is ordinary year.\n");
}
sum=0,check=0,check1=0,check2=0,check3=0,leap=0,sum1=0,sum2=0;
printf("\n");
}
}



input:
=======

2000
3600
4515
2001
22000
22055
22220
330000
330015
330220
456464484515645448647512343674234567564234564784234564754742345647424564
456464484515645448647512343674234567564234564784234564754742345647424565
456464484515645448647512343674234567564234564784234564754742345647424566
456464484515645448647512343674234567564234564784234564754742345647424567
456464484515645448647512343674234567564234564784234564754742345647424568
456464484515645448647512343674234567564234564784234564754742345647424569
456464484515645448647512343674234567564234564784234564754742345647424560
456464484515645448647512343674234567564234564784234564754742345647424500
234324234245646448451564544864751234367423456756423456478423456475474234564742456
23423423
65678645656377386585675675675622789235723451275172892374016526347623483274237487123848912347891237489123561237612734612375617234672461237123567123465781465714657136475617856127651237845173657813465781263478561234787856781349658716345786134785617823651782367845123675647823563784657834657834657834657861347856134785634786578134657816347856178567182346578134657823465723456123761789035617856163417454
838286831260478655
838286831260478400
838286831260478650
838286831260478655
228623681252857800
228623681252857815
228623681252857830
228623681252857810
2000
3600
4515
2001


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]

check this input & output

Posted: Wed Dec 17, 2003 6:25 pm
by osan
please check this input & output. i hope these will help u.

INPUT
2200
3000
6000
2000
10500
5500
OUTPUT
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.
& one thing ur code is giving a extra blank line after last output. be careful about this.

runtime error

Posted: Fri Dec 19, 2003 12:39 pm
by cfalcon
hi,
i've just recently registered to this website and i tried to send in a program...#10070...the leap year, huluculu year and the bulukulu year one. however, when i sent it, it said 'Runtime Error (SIGXFSZ)'. what does this mean? and how do i fix it? everything seems to be working on my computer...and this error msg is not explained in the "how to interpret judge replies" section. plz help. thanx a lot.

10070

Posted: Sat Dec 20, 2003 7:29 pm
by cfalcon
this program seems to be working fine on my computer but gives me runtime error when i submit. this is my code:

[code]#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
ifstream fin;
ofstream fout;
fin.open("myprog.in");
fout.open("myprog.out");
while (!fin.eof())
{
char y[10000];
bool l;
fin.getline(y,10000,'\n');
//fin.ignore(1,'\n');
int n=strlen(y),sum=0,i,sume=0,sumo=0;
bool sth=true;
short ld=static_cast<int>(y[n-1])-48,sd=static_cast<int>(y[n-2])-48,td=static_cast<int>(y[n-3])-48,fd=static_cast<int>(y[n-4])-48;
l=(((sd*10+ld)%4==0) && (sd!=0 || ld!=0)) || (((fd*10+td)%4==0) && (sd==0 && ld==0));
for (i=0;i<n;i++)
{
sum=sum+(static_cast<int>(y[i])-48);
if (i%2==0) sumo=sumo+(static_cast<int>(y[i])-48);
else sume=sume+(static_cast<int>(y[i])-48);
}
if (l) { sth=false; fout<<"This is leap year.\n"; }
if (sum%3==0 && (ld==0 || ld==5)) {sth=false; fout<<"This is huluculu festival year.\n"; }
if ((l) && ((ld==0 || ld==5) && sumo==sume)) {sth=false; fout<<"This is bulukulu festival year.\n"; }
if (sth) fout<<"This is an ordinary year.\n";
if (!fin.eof()) fout<<"\n";
}
fin.close();
fout.close();

}[/code]

it says RUNTIME ERROR SIGXFSZ. i couldn't find it's meaning anywhere on this site or forum. on google i found it meant file size limit exceeded but i can't see how that's happening in my case. any help would be really appreciated. i've submitted lots of times and i get the same error. thanx a lot.

i think u have no need to find much.

Posted: Fri Dec 26, 2003 1:21 pm
by osan
as i i know they send u a email. if u didn't disable the option.
there they always tell disucss about the problem. if u dont get WA.

GOOD LUCK

Posted: Sat Feb 28, 2004 8:38 am
by ranjit
a number is divisible by 11 if difference between the sum of its even digits and odd digits is divisible by 11

eg 919105[/quote]

Posted: Wed Mar 03, 2004 12:25 am
by Kentaro
That's not true either. Think of 22000. The difference between the sum of the even and odd digits is 4 which is not divisible by 11. Does anyone have a good rule for determining if a number is divisible by 11?

EDIT: Sorry, that post is correct. A number is divisible by 11 if the difference between the sum of its even digits and the sum of its odd digits is divisible by 11. I misunderstood what was posted. In the case of 22000 the sum of the even digits is 2 and the sum of the odd digits is 2. The difference is 0 and 0 mod 11 is 0. Thus 22000 is divisible by 11. A nice explanation of many of these rules is here:

http://mathforum.org/k12/mathtips/ward2.html

My misunderstanding is because I thought of even digits as being any digits in the entire number that were even as opposed to digits in even-numbered positions in the entire number.

10070

Posted: Sun Mar 07, 2004 8:18 am
by Ferdous
I just can't figure out why I am receiving WA. Please help me.
Here's my code:

(deleted later..... Got AC :D )

Posted: Sun Mar 07, 2004 8:38 am
by shamim
Here is a quote from the problem statement.
and the Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year).


so 110055 is not a bulukulu year. But your program gives bulukulu for this year. :wink: