fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. char a[501];
  6. int b[500];
  7. int z[11]={1,1,2,6,24,120,720,5040,40320,362800,3628000};
  8. int prime[95]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,
  9. 73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,
  10. 179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,
  11. 283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,
  12. 419,421,431,433,439,443,449,457,461,463,467,479,487,491,499};
  13. int t,no,i,c,j,priou,k;
  14. long int count1,count2,count3;
  15. scanf("%d",&t);
  16. count3=(pow(10,9)+7);
  17. while(t!=0)
  18. {
  19. no=0;
  20. i=0;
  21. while((c=getchar())!='\n')
  22. {
  23. a[i]=c;
  24.  
  25. i++;
  26. }
  27. no=i;
  28. a[i]='\n';
  29.  
  30. for(i=0;i<no;i++)
  31. {
  32.  
  33. for(j=i+1;(a[i]>48 && j<no);j++)
  34. {
  35. if(a[i]==a[j])
  36. {
  37. b[i]++;
  38. a[j]=4;
  39. }
  40. }
  41. }
  42.  
  43. count1=count2=1;
  44. i=0;
  45. while(1)
  46. {
  47. priou=0;
  48. if(no>=prime[i])
  49. {
  50. k=no;
  51. while(k!=0)
  52. {
  53. j=k/prime[i];
  54. priou=priou+j;
  55. k=j;
  56. }
  57.  
  58. count1=pow(prime[i],priou);
  59. count1=count2*count1;
  60. count2=count1%count3;
  61.  
  62. i++;
  63. }
  64.  
  65. else if(no<prime[i])
  66. break;
  67.  
  68. }
  69. for(j=0;j<no;j++)
  70. {
  71. if(b[j]>1)
  72. {
  73. count1=count2/z[b[j]];
  74. count2=count1;
  75. }
  76. }
  77. printf("%ld\n",count2);
  78. t--;
  79. }
  80. return 0;
  81. }
  82.  
Runtime error #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
Standard output is empty