fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <cstdio>
  4. //47!,48! WA
  5. using namespace std;
  6. int PR[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
  7. int AN[168]={0};
  8. int ana_std(int inn)
  9. {
  10. //int K= Prime.size();
  11. int K=168;
  12. int ret=0;
  13. for (int i=0; PR[i]<= inn && i< K; i++)
  14. {
  15. int that= PR[i];
  16. while(inn % that==0)
  17. {
  18. inn /= that;
  19. AN[i] +=1;
  20. if (inn==1)
  21. return ret;
  22. }
  23. }
  24. if (ret>1)
  25. return ret;
  26. else
  27. return(1);
  28. }
  29. void ACM160(int N)
  30. {
  31. for (int t=0;t<168; t++)
  32. {
  33. AN[t]=0;
  34. }
  35. for (int x=2; x<=N; x++)
  36. {
  37. ana_std(x);
  38. }
  39. cout<<setw(3)<<setiosflags(ios::fixed)<<N<<"! =";
  40. //printf("%3d! = ",N);
  41.  
  42.  
  43. for (int i=0; i<168; i++)
  44. {
  45.  
  46. if (AN[i]>0)
  47. {
  48. cout <<setw(3)<<setiosflags(ios::fixed)<<AN[i];
  49. //printf("%3d",AN[i]);
  50. if (i==14 && AN[i+1]!=0)
  51. {
  52. if (N==100)
  53. cout<<endl<<" ";
  54. else
  55. cout<<endl<<" ";
  56. }
  57. }else
  58. {
  59. cout<<endl;
  60. break;
  61. }
  62. }
  63. }
  64. int main()
  65. { int N;
  66. while(cin>>N)
  67. {
  68. if (N>=2 && N<=100)
  69. {
  70. ACM160(N);
  71. }else if (N==1)
  72. {
  73. cout<<setw(3)<<setiosflags(ios::fixed)<<N<<"! ="<<endl;
  74. //printf("%3d",N);
  75. //printf("! =\n");
  76. continue;
  77. }
  78. else
  79. break;
  80. }
  81. //getchar();
  82. return 0;
  83. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
Standard output is empty