## 10338 - Mischievous Children

All about problems in Volume CIII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Hi lord_burgos!!

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

Thanks anyway!!
p!ter
New poster

Posts: 11
Joined: Thu Nov 18, 2004 8:55 pm

lord_burgos wrote:
Code: Select all
`Your welcomDelete after AC`

lord_burgos
New poster

Posts: 43
Joined: Mon Oct 13, 2003 4:54 pm
Location: Mexico

### 10338 always WA

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.
jan_holmes
Experienced poster

Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore

### 10338 - critical I/O, always WA

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!

[_TANG_]
New poster

Posts: 15
Joined: Wed May 04, 2005 12:28 am
Location: Mexico

### Help plz!

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:6WEDDINGHAPPYADAMABABAAAAAAAAAAAAAAAAAMULTIPLICATION`

Code: Select all
`Output:Data set 1: 2520Data set 2: 60Data set 3: 12Data set 4: 190Data set 5: 1Data set 6: 3632428800`

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

__________________
[_TANG_]

[_TANG_]
New poster

Posts: 15
Joined: Wed May 04, 2005 12:28 am
Location: Mexico

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.
sumankar
A great helper

Posts: 288
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta

double works fine also.
WR
Experienced poster

Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

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_]

[_TANG_]
New poster

Posts: 15
Joined: Wed May 04, 2005 12:28 am
Location: Mexico

Thnx sumankar I found my mistake ... a hidden one! ... Now I've got AC :

[_TANG_]
New poster

Posts: 15
Joined: Wed May 04, 2005 12:28 am
Location: Mexico

[_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.
sumankar
A great helper

Posts: 288
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta

### 10338 - P.E.

Hi everybody. Can someone explain me the output format in a clear way, please...
10024 - Guayoyo has Curled Up the Cube!
guayoyo
New poster

Posts: 11
Joined: Wed Aug 17, 2005 5:59 pm
Location: Caracas, Venezuela

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.
Last edited by nazeen on Sun Nov 05, 2006 11:13 am, edited 1 time in total.
nazeen
New poster

Posts: 3
Joined: Sun Oct 29, 2006 6:16 am
Location: Dhaka, Bangladesh

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
helloneo
Guru

Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### RTE 10338[Mischievous Children]

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`
No venture no gain

with best regards
------------------------
ishtiaq ahmed
ishtiaq ahmed
Learning poster

Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

### Re: 10338 - Mischievous Children

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;}`
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

PreviousNext

Return to Volume CIII

### Who is online

Users browsing this forum: No registered users and 0 guests