Page 3 of 4

Posted: Sat Jan 15, 2005 5:53 pm
by p!ter
Hi lord_burgos!!

Your code doesn't work!!!
I found mistake in my and got Accepted :D

Thanks anyway!!

Posted: Mon Jan 17, 2005 9:03 am
by lord_burgos
lord_burgos wrote:

Code: Select all

Your welcom

Delete after AC

10338 always WA

Posted: Sat Apr 23, 2005 2:15 pm
by jan_holmes
Anyone could help why I got WA ????

{$N+}
type
jum = array [1..28] of longint;
jum2 = array [1..28] of longint;
var
n:longint;
i,j,k:longint;
jumlah1,jumlah3,jumtot:extended;
jumlah:jum;
jumlah2:jum2;
m:string;
begin
readln(n);
for i:= 1 to n do
begin
readln(m);
jumlah1:=1;
jumlah3:=1;
for j:= 1 to 26 do
begin
jumlah[j]:=0;
end;
for j:= 1 to length(m) do
begin
jumlah1:=jumlah1*j;
end;
for j:= 1 to length(m) do
begin
case m[j] of
'A' : inc(jumlah[1]);
'B' : inc(jumlah[2]);
'C' : inc(jumlah[3]);
'D' : inc(jumlah[4]);
'E' : inc(jumlah[5]);
'F' : inc(jumlah[6]);
'G' : inc(jumlah[7]);
'H' : inc(jumlah[8]);
'I' : inc(jumlah[9]);
'J' : inc(jumlah[10]);
'K' : inc(jumlah[11]);
'L' : inc(jumlah[12]);
'M' : inc(jumlah[13]);
'N' : inc(jumlah[14]);
'O' : inc(jumlah[15]);
'P' : inc(jumlah[16]);
'Q' : inc(jumlah[17]);
'R' : inc(jumlah[18]);
'S' : inc(jumlah[19]);
'T' : inc(jumlah[20]);
'U' : inc(jumlah[21]);
'V' : inc(jumlah[22]);
'W' : inc(jumlah[23]);
'X' : inc(jumlah[24]);
'Y' : inc(jumlah[25]);
'Z' : inc(jumlah[26]);
end;
end;
for j:= 1 to 26 do
begin
jumlah2[j]:=1;
for k:= 1 to jumlah[j] do
begin
jumlah2[j]:=jumlah2[j]*k;
end;
end;
for j:= 1 to 26 do
begin
jumlah3:=jumlah3*jumlah2[j];
end;
jumtot:=jumlah1 / jumlah3;
writeln('Data set ',i,': ',jumtot:0:0);
end;
end.

10338 - critical I/O, always WA

Posted: Tue May 10, 2005 7:54 pm
by [_TANG_]
I've solve this problem, all my I/O tests are OK (I used a calculator) ... Can anyone give me a critical I/O to test my code?

Thnx! :cry:

Help plz!

Posted: Tue May 31, 2005 1:06 am
by [_TANG_]
Maybe I'm calculating the formula in wrong way .... I calculate this N! / [fact(any letter repited) * fact(...)]

And all mi I/O tests are right ....

Code: Select all


Input:

6
WEDDING
HAPPY
ADAM
ABABAAAAAAAAAAAAAAAA
A
MULTIPLICATION

Code: Select all


Output:

Data set 1: 2520
Data set 2: 60
Data set 3: 12
Data set 4: 190
Data set 5: 1
Data set 6: 3632428800

Help please ... I'm going mad because of this problem

__________________
[_TANG_]

Posted: Tue May 31, 2005 6:22 am
by sumankar
The number of arrangements will always be able to fit into an unsigned long int
-tells us to use atleast unsigned long.
Note that 12! is the largest factorial that can fit into an unsigned long int
- tells us to be careful and check for overflows.

So while calculating the result, reduce and calculate, instead of calculating the numerator, the denominator & then division.

HTH,
Regards,
Suman.

Posted: Tue May 31, 2005 7:54 am
by WR
double works fine also.

Posted: Tue May 31, 2005 3:50 pm
by [_TANG_]
Mmmm ... sumankar tell me if I'm wrong, I used long long int because of this:
Note that 12! is the largest factorial that can fit into an unsigned long int
I understand that there will be words of length larger than 12 but smaller than 21 ... and long long int can handle 20! isn't it?

Other doubt I have is ... You said ->
reduce and calculate, instead of calculating the numerator, the denominator & then division.
Can results vary if I just use the formula?

Thnx

_______________
[_TANG_]

Posted: Tue May 31, 2005 5:13 pm
by [_TANG_]
Thnx sumankar I found my mistake ... a hidden one! ... Now I've got AC : :D

Posted: Wed Jun 01, 2005 6:01 am
by sumankar
[_TANG_] wrote:Can results vary if I just use the formula?
On pen and paper no!With a computer, it might if there is overflow.

10338 - P.E.

Posted: Wed Sep 07, 2005 10:41 pm
by guayoyo
Hi everybody. Can someone explain me the output format in a clear way, please...

Posted: Fri Nov 03, 2006 5:16 pm
by nazeen
My code works with sample I/O... but getting WA. I read the related threads but couldn't figure the bug out.. Here is my code...

Code: Select all

 code deleted after ac
Thanx helloneo... I corrected the portion and got AC. :D

Posted: Sun Nov 05, 2006 4:44 am
by helloneo

Code: Select all

for (i=0; i<len;i++) {
    if (s[i]!=s[i-1]) {
        ...
        ...
this part is not ok..
be careful when i = 0

RTE 10338[Mischievous Children]

Posted: Sat Jul 28, 2007 3:33 pm
by ishtiaq ahmed
I am facing RTE. Can anybody help me? Is my algorithm is correct for solving this problem? Here is my code

Code: Select all

cut after AC

Re: 10338 - Mischievous Children

Posted: Mon Jul 28, 2008 1:05 pm
by Obaida
I don't know why I am WA???

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
	char st[21],a[21];
	int n,i,j,k,r,len,num[21],c=0;
	bool found,enter;
	scanf("%d",&n);getchar();
	while(n--)
	{
		c++;
		gets(st);
		len = strlen(st);j=0;k=1;
		for(i=0;st[i];i++)
		{
			if(i>0)
			{
				found=0;
				for(j=0;j<k;j++)
				{
					if(a[j]==st[i])
					{
						found=1;
						num[j]+=1;
						break;
					}
				}
				if(!found){a[k]=st[i];num[k]=1;k++;}
			}
			else {a[0]=st[i];num[0]=1;}
		}
		long long int sum=1,sumr=0,temp=1;
		r=len-k;
		enter=1;
		for(i=0;i<k;i++)if(num[i]>1){for(j=1;j<=num[i];j++)temp*=j;sumr+=temp;}
		for(i=1;i<=len;i++){sum*=i;if(sum%sumr==0&&enter==1){sum/=sumr;enter=0;}}
		printf("Data set %d: %lld\n",c,sum);
	}
	return 0;
}