fork(1) download
  1. //
  2. // SmallFactorials.cpp
  3. // 3
  4. //
  5. // Created by Chintan Shah on 18/08/13.
  6. // Copyright (c) 2013 Chintan Shah. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10. #include <iostream>
  11. #include <math.h>
  12. #include <vector>
  13. #include <algorithm>
  14. using namespace std;
  15. inline int FAST_IO()
  16. { int x=0;
  17. char ch;
  18. ch=getchar_unlocked();
  19. x = ch-48;
  20. while ((ch=getchar_unlocked()) >= 48 && ch <= 57)
  21. x=x*10+ch-48;
  22. return x;
  23. }
  24.  
  25.  
  26. int main()
  27. {
  28. int b;
  29. int t=FAST_IO();
  30. cout<<t<<endl;
  31. int a[200];
  32. int m=0,temp;
  33. while(t>0)
  34. {
  35. a[0]=1;
  36. int x=FAST_IO();
  37. cout<<x<<endl;
  38. int y=x;
  39. for(;y>=2;y--)
  40. {
  41. temp = 0;// you did not initialise temp =0
  42. for(int i=0;i<=m;i++)
  43. {
  44. b=(a[i]*y)+temp;//earlier it was temp in place of variable b
  45. a[i]=b%10;//same as above
  46. temp=b/10;// same as above
  47. }
  48. while(temp>0)
  49. {
  50. a[++m]=temp%10;
  51. temp=temp/10;
  52. }
  53. }
  54.  
  55. t--;
  56.  
  57. for(int i=m;i>=0;i--)
  58. {
  59. cout<<a[i];
  60.  
  61. }
  62. cout<<endl;
  63. for(int i=m;i>=0;i--)
  64. {
  65. a[i]=0;
  66.  
  67. }
  68. m=0;
  69. }
  70. return 0;
  71.  
  72.  
  73. }
  74.  
Success #stdin #stdout 0s 2688KB
stdin
1
100
stdout
1
100
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000