fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <cstdio>
  4. using namespace std;
  5. 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};
  6. int AN[168]={0};
  7. int ana_std(int inn)
  8. {
  9. //int K= Prime.size();
  10. int K=168;
  11. int ret=0;
  12. for (int i=0; PR[i]<= inn && i< K; i++)
  13. {
  14. int that= PR[i];
  15. while(inn % that==0)
  16. {
  17. inn /= that;
  18. AN[i] +=1;
  19. if (inn==1)
  20. return ret;
  21. }
  22. }
  23. if (ret>1)
  24. return ret;
  25. else
  26. return(1);
  27. }
  28. void ACM160(int N)
  29. {
  30. for (int t=0;t<168; t++)
  31. {
  32. AN[t]=0;
  33. }
  34. for (int x=2; x<=N; x++)
  35. {
  36. ana_std(x);
  37. }
  38. //cout<<setw(3)<<setiosflags(ios::fixed)<<N<<"! =";
  39. printf("%3d! = ",N);
  40.  
  41.  
  42. for (int i=0; i<168; i++)
  43. {
  44.  
  45. if (AN[i]>0)
  46. {
  47. //cout <<setw(3)<<setiosflags(ios::fixed)<<AN[i];
  48. printf("%3d",AN[i]);
  49. if (i==14)
  50. {
  51. if (N==100)
  52. cout<<endl<<" ";
  53. else
  54. cout<<endl<<" ";
  55. }
  56. }else
  57. {
  58. cout<<endl;
  59. break;
  60. }
  61. }
  62. }
  63. int main()
  64. { int N;
  65. while(cin>>N)
  66. {
  67. if (N>=2 && N<=100)
  68. {
  69. ACM160(N);
  70. }else if (N==1)
  71. {
  72. //cout<<setw(3)<<setiosflags(ios::fixed)<<N<<"! ="<<endl;
  73. printf("%3d",N);
  74. printf("! =\n");
  75. continue;
  76. }
  77. else
  78. break;
  79. }
  80. //getchar();
  81. return 0;
  82. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Standard output is empty