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 t=FAST_IO();
  29. cout<<t<<endl;
  30. int a[200];
  31. int m=0,temp;
  32. while(t>0)
  33. {
  34. a[0]=1;
  35. int x=FAST_IO();
  36. cout<<x<<endl;
  37. int y=x;
  38. for(;y>=2;y--)
  39. {
  40. for(int i=0;i<=m;i++)
  41. {
  42. temp=(a[i]*y)+temp;
  43. a[i]=temp%10;
  44. temp=temp/10;
  45. }
  46. while(temp>0)
  47. {
  48. a[++m]=temp%10;
  49. temp=temp/10;
  50. }
  51. }
  52.  
  53. t--;
  54.  
  55. for(int i=m;i>=0;i--)
  56. {
  57. cout<<a[i];
  58.  
  59. }
  60. cout<<endl;
  61. for(int i=m;i>=0;i--)
  62. {
  63. a[i]=0;
  64.  
  65. }
  66. m=0;
  67. }
  68. return 0;
  69.  
  70.  
  71. }
Success #stdin #stdout 0s 3344KB
stdin
1
100
stdout
1
100
-3