fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class LongNumber
  5. {
  6. public:
  7.  
  8. LongNumber()
  9. {
  10. }
  11.  
  12. LongNumber(std::vector <int> a)
  13. {
  14. box.resize(a.size());
  15. for (int i = 0; i < a.size(); i++)
  16. {
  17. box[i] = a[i];
  18. }
  19. }
  20.  
  21. void pushBack(int number)
  22. {
  23. box.push_back(number);
  24. }
  25.  
  26. int getSize() const
  27. {
  28. return box.size();
  29. }
  30.  
  31. int getNumber(int pos) const
  32. {
  33. return box[pos];
  34. }
  35.  
  36. void reverseUp()
  37. {
  38. int condition = box.size() / 2;
  39. int glass, last = box.size() - 1;
  40.  
  41. for (int i = 0; i < condition; i++)
  42. {
  43. glass = box[i];
  44. box[i] = box[last - i];
  45. box[last - i] = glass;
  46. }
  47. }
  48.  
  49. void reverseBack()
  50. {
  51. int condition = box.size() / 2;
  52. int glass, last = box.size() - 1;
  53.  
  54. for (int i = 0; i < condition; i++)
  55. {
  56. glass = box[i];
  57. box[i] = box[last - i];
  58. box[last - i] = glass;
  59. }
  60. }
  61.  
  62. void print()
  63. {
  64. int pos = 0;
  65.  
  66. while (!box[pos])
  67. {
  68. pos++;
  69. }
  70.  
  71. for (int i = pos; i < box.size(); i++)
  72. {
  73. std::cout << box[i];
  74. }
  75. }
  76.  
  77. LongNumber operator* (LongNumber & obj)
  78. {
  79. int length = box.size() + obj.getSize() + 1;
  80. std::vector <int> c;
  81. c.resize(length);
  82.  
  83. for (int i = 0; i < box.size(); i++)
  84. {
  85. for (int j = 0; j < obj.getSize(); j++)
  86. {
  87. c[i + j] += box[i] * obj.getNumber(j);
  88. }
  89. }
  90.  
  91. for (int i = 0; i < c.size() - 1; i++)
  92. {
  93. c[i+1] += c[i] / 10;
  94. c[i] = c[i] % 10;
  95. }
  96.  
  97. int last = c.size() - 1;
  98.  
  99. while (!c[last])
  100. last--;
  101. c.resize(last + 1);
  102. return LongNumber(c);
  103. }
  104.  
  105. LongNumber &operator= (const LongNumber &obj)
  106. {
  107.  
  108. box.resize(obj.getSize());
  109.  
  110. for (int i = 0; i < obj.getSize(); i++)
  111. {
  112. box[i] = obj.getNumber(i);
  113. }
  114.  
  115. return *this;
  116. }
  117.  
  118. private:
  119. std::vector <int> box;
  120. };
  121.  
  122. int main()
  123. {
  124. int k;
  125. std::cin >> k;
  126.  
  127. LongNumber a, b, c;
  128. a.pushBack(5);
  129. a.pushBack(5);
  130. b.pushBack(3);
  131. b.pushBack(6);
  132. c.pushBack(1);
  133.  
  134. a.reverseUp();
  135. b.reverseUp();
  136.  
  137. for (int i = 0; i < k - 1; i++ )
  138. {
  139. c = c * a;
  140. }
  141.  
  142. c = c * b;
  143.  
  144. c.reverseBack();
  145. c.print();
  146.  
  147.  
  148. }
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
36