Advertisement
dimuster

инфа

Jan 25th, 2022 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. ФАКТОРИАЛ
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define int long long
  8. #define ld long double
  9. #define v vector
  10. #define min(a, b) (a < b ? a : b)
  11. #define max(a, b) (a > b ? a : b)
  12.  
  13.  
  14. void write6(int x) {
  15. int m = 100000;
  16. while (m > 0) {
  17. cout << x / m;
  18. x %= m;
  19. m /= 10;
  20. }
  21. }
  22.  
  23. signed main(signed argc, char* argv[]) {
  24. ios_base::sync_with_stdio(false);
  25. cin.tie(NULL);
  26. // cout.setf(ios::fixed);
  27. // cout.precision(0);
  28. // freopen("input.txt", "r", stdin);
  29. // freopen("output.txt", "w", stdout);
  30.  
  31. int n = 1000, d = 1000000;
  32. v<int> A(n + 1, 0);
  33. A[0] = 1;
  34. int xxx;
  35. cin >> xxx;
  36.  
  37. for (int k = 2; k <= xxx; k++) {
  38. int r = 0;
  39. for (int i = 0; i <= n; i++) {
  40. int s = A[i] * k + r;
  41. A[i] = s % d;
  42. r = s / d;
  43. }
  44. }
  45.  
  46. int ind = n;
  47. while (!A[ind]) ind--;
  48. cout << A[ind];
  49. for (int i = ind - 1; i >= 0; i--) write6(A[i]);
  50.  
  51. return 0;
  52. }
  53.  
  54.  
  55. ВОЗВЕДЕНИЕ В СТЕПЕНЬ
  56.  
  57. #include <bits/stdc++.h>
  58.  
  59. using namespace std;
  60.  
  61. #define int long long
  62. #define ld long double
  63. #define v vector
  64. #define min(a, b) (a < b ? a : b)
  65. #define max(a, b) (a > b ? a : b)
  66.  
  67.  
  68. void write6(int x) {
  69. int m = 100000;
  70. while (m > 0) {
  71. cout << x / m;
  72. x %= m;
  73. m /= 10;
  74. }
  75. }
  76.  
  77. signed main(signed argc, char* argv[]) {
  78. ios_base::sync_with_stdio(false);
  79. cin.tie(NULL);
  80. // cout.setf(ios::fixed);
  81. // cout.precision(0);
  82. // freopen("input.txt", "r", stdin);
  83. // freopen("output.txt", "w", stdout);
  84.  
  85. int n = 1000, d = 1000000;
  86. v<int> A(n + 1, 0);
  87. int a, b;
  88. cin >> a >> b;
  89. A[0] = a;
  90. b--;
  91.  
  92. while (b--) {
  93. int r = 0;
  94. for (int i = 0; i <= n; i++) {
  95. int s = A[i] * a + r;
  96. A[i] = s % d;
  97. r = s / d;
  98. }
  99. }
  100.  
  101. int ind = n;
  102. while (!A[ind]) ind--;
  103. cout << A[ind];
  104. for (int i = ind - 1; i >= 0; i--) write6(A[i]);
  105.  
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement