Page 4 of 4

Re: 10338 - Mischievous Children

Posted: Sun Jan 04, 2009 5:45 pm
by abid_iut
getting CE!!
I thought unsigned long long can handle 20!
is it? or any other problem
where should I change
here is the code:

Code: Select all

Removed
pls help :(

Re: 10338 - Mischievous Children

Posted: Sun Jan 04, 2009 5:57 pm
by helloneo
abid_iut wrote:getting CE!!
I thought unsigned long long can handle 20!
is it? or any other problem
where should I change
2432902008176640000 is a representation of 32 bit integer
You should code it like 2432902008176640000LL or 2432902008176640000ULL

Re: 10338 - Mischievous Children

Posted: Sun Jan 04, 2009 6:18 pm
by abid_iut
I have changed the code accordingly
But now it is WA
pls anyone help
here is the code:

Code: Select all

Removed

Re: 10338 - Mischievous Children

Posted: Mon Jan 05, 2009 4:41 pm
by helloneo
abid_iut wrote:I have changed the code accordingly
But now it is WA
pls anyone help
here is the code:
I don't fully understand your code.. but, what if k == 0 ??

Re: 10338 - Mischievous Children

Posted: Mon Jan 05, 2009 6:20 pm
by abid_iut
i have considered k=0;
but still it is WA
here is the code:

Code: Select all

#include<stdio.h>
        #include<string.h>
        #include<math.h>

        char line[100];
        long same[100];
        long long ans,fact;
        int i,j;

        long long factorial[22]={1,2,6,24,120,720,5040,4320,362880,3628800LL,39916800LL,479001600LL,6227020800LL,87178291200LL,1307674368000LL,20922789888000LL,355687428096000LL,6402373705728000LL,121645100408832000LL,2432902008176640000LL};

        int main()
        {
           long n,k,count,t,l,it,div;
           scanf("%ld",&n);
           for(it=1;it<=n;it++){
              gets(line);
              k=0;count=0;
              l=strlen(line);
              for(i=0;i<=l-1;i++){
                 for(j=0;j<=l-1;j++){
                    if(line[i]==line[j] && (line[i]!='*' || line[j]!='*') && line[i]!=' '){
                       count++;
                       if(count>1)line[j]='*';
                    }
                 }
                 if(count>1){same[k]=count;k++;}
                 count=0;
              }
			  if(k>0){
              i=0;
              div=same[0]-1;
              fact=factorial[l-1];
              ans=fact/factorial[div];
              for(i=1;i<k;i++){
               div=same[i]-1;
                 ans=ans/factorial[div];
              }
              printf("Data set %ld: %lld\n",it,ans);
			  }
			  if(k==0){
				  printf("Data set %ld: %lld\n",it,factorial[l-1]);
			  }
           }
           return 0;
        }
pls help :(

Re: 10338 - Mischievous Children

Posted: Thu Jun 23, 2011 6:34 am
by plamplam
Well well, look what we have here. The problem description is actually wrong, although the problem itself is not. It says that
"The number of arrangements will always be able to fit into an unsigned long int. Note that 12! is the largest factorial that can fit into an unsigned long int." Notice that it should be 20 instead of 12 and that 20! easily fits into an unsigned long long int. :D
Anyway this is indeed a trivial problem, and you should by no means get Wrong Answer. Just use unsigned long long int, but in case somehow you find yourself in a "Wrong Answer" queue, then here are some test cases. Note that the output in my program for a blank line is 1 but Im not sure if this is going to be included in the judge data.

Code: Select all

13
L
LOL
MICROSOFTSUCKS
WHATCANWEDOTOHELP
BAOBABTREE
ACCCACCCCCCCACC
AAAAAAAAAAAC
AAAAAAAAAAAAAAAA
AAAAAACAAAAACAACA
IGOTACYAY
ICANTREALLYHELPU
WHOCARESTHOUGH
ABCDEFGHIJKLMNOPQRST

Code: Select all

Data set 1: 1
Data set 2: 3
Data set 3: 3632428800
Data set 4: 5557616064000
Data set 5: 151200
Data set 6: 455
Data set 7: 12
Data set 8: 1
Data set 9: 680
Data set 10: 90720
Data set 11: 871782912000
Data set 12: 7264857600
Data set 13: 2432902008176640000
If you still get a Wrong Answer then no one can help you. Sorry :wink: :wink:

why i am getting wrong answer for 10338 no problem

Posted: Sat Jun 08, 2013 12:17 pm
by safait
here is my code:

Code: Select all

#include<stdio.h>
unsigned long long int binnas(int i)
{
    unsigned long long int n=1;
    for(;i>1;) n*=i--;
    return n;
}

int main()
{
    unsigned long long int n,r;
    int i,j,x,count,in,in1;
    char arr[21];
    in1=1;
    scanf("%d",&in);
    getchar();
    while(in1++<=in){
    for(i=0;arr[i-1]!='\n';i++)
        arr[i]=getchar();
   r=binnas(--i);
   count=1;
   for(j=0;j<i;j++){
        for(x=0;x<i;x++)
            if(arr[j]==arr[x] && x!=j){
                count++;
                arr[x]='Z'+x+j+1;
            }
        if(count>1){
       r/=binnas(count);
       count=1;}
   }
    printf("Data set %d: %llu\n",in1-1,r);
    }
    return 0;
}
for which input ,it get wrong answer.

Re: why i am getting wrong answer for 10338 no problem

Posted: Sun Jun 09, 2013 4:52 am
by sohel
http://acm.uva.es/board/viewtopic.php?f=20&t=1353

Search the board first using the search option located at top-right. Don't create a new thread for a problem that already exists. Make your post in an existing thread.

Re: why i am getting wrong answer for 10338 no problem

Posted: Mon Jun 10, 2013 1:34 pm
by safait
sohel wrote:http://acm.uva.es/board/viewtopic.php?f=20&t=1353

Search the board first using the search option located at top-right. Don't create a new thread for a problem that already exists. Make your post in an existing thread.
i am not getting perfect answer .
if u see my code carefully then u find my code not able to calculate 20!.
i am want that what is the way to calculate 20!

Re: why i am getting wrong answer for 10338 no problem

Posted: Tue Jun 11, 2013 12:49 am
by brianfry713
Your code is producing a RE on the sample input. 20! will fit in long long. Also see:
http://www.algorithmist.com/index.php/BigNum

Re: 10338 - Mischievous Children

Posted: Tue Apr 08, 2014 9:10 am
by uDebug
plamplam,
Thanks for the great test cases.

Re: why i am getting wrong answer for 10338 no problem

Posted: Tue Apr 08, 2014 9:12 am
by uDebug
Replying to follow the thread.