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
Moderator: Board moderators
Code: Select all
Removed
2432902008176640000 is a representation of 32 bit integerabid_iut wrote:getting CE!!
I thought unsigned long long can handle 20!
is it? or any other problem
where should I change
Code: Select all
Removed
I don't fully understand your code.. but, what if k == 0 ??abid_iut wrote:I have changed the code accordingly
But now it is WA
pls anyone help
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;
}
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
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;
}
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!