fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4.  
  5. typedef std::vector<int> DType;
  6.  
  7. //funny for poor license.
  8. //if you built in the Commercial were the this code. you must pay me $10 par use.LOL!!!
  9. //i think to better the not use for Commercial. so not use any flagment of this code.
  10. //and you must not able to modify this ALL code.
  11. //ふっふっふ、今度は可笑しな強制力は無いだろう。
  12.  
  13. std::size_t GetDigit(int N){
  14. std::size_t D = 0;
  15.  
  16. while (N != 0){
  17. N /= 10;
  18. D++;
  19. }
  20.  
  21. return D;
  22.  
  23. }
  24.  
  25. int SnipeDigit(int N, std::size_t P){
  26. int M = 0;
  27. int R = 10;
  28.  
  29. for (std::size_t i = 0; i < P; i++){
  30. M = N%R;
  31. N /= R;
  32. }
  33.  
  34. return std::abs(M);
  35. }
  36.  
  37.  
  38. int Sign(int N){
  39. return N >= 0 ? 1 : -1;
  40. }
  41.  
  42. DType MakeHoge(int A, int B){
  43.  
  44. std::size_t BN = GetDigit(B);
  45. DType R;
  46.  
  47. R.push_back(A);
  48. R.push_back(B);
  49.  
  50. for (std::size_t i = 1; i <= BN; i++){
  51. R.push_back(std::abs(A)*SnipeDigit(B,i));
  52. }
  53.  
  54. return R;
  55. }
  56.  
  57. bool Show(DType& vec){//値がマイナスの時のことは考えてない・・・。Orz
  58.  
  59. int MD = GetDigit(vec[0]) + GetDigit(vec[1])+1;
  60. int Pod = 2;
  61. int Mul = 1;
  62.  
  63. std::cout << std::setw(MD) << std::right << vec[0] << std::endl;
  64. std::cout <<'X'<< std::setw(MD-1) << std::right << vec[1] << std::endl;
  65. for (int i = 0; i < MD; i++) std::cout << '-';
  66. std::cout<<std::endl;
  67. //-------
  68. for (std::size_t i = 0; i < vec.size()-Pod; i++){
  69. if (vec[Pod + i] == 0){
  70. Mul *= 10;
  71. continue;
  72. }
  73. auto T = vec[i + Pod];
  74. std::cout << std::setw(MD-i+GetDigit(Mul-1)) << std::right << T*Mul << std::endl;
  75. Mul = 1;
  76. }
  77. //-------
  78. for (int i = 0; i < MD; i++) std::cout << '-';
  79. std::cout<<std::endl;
  80. std::cout << std::setw(MD) << std::right << vec[0]*vec[1] << std::endl;
  81. return true;
  82. }
  83.  
  84.  
  85. int main(){
  86. DType R;
  87.  
  88. R = MakeHoge(1234, 567);
  89. Show(R);
  90. R = MakeHoge(1234, 1001);
  91. Show(R);
  92. R = MakeHoge(99, 909090);
  93. Show(R);
  94. R = MakeHoge(12345, 12345);//両方の数が7万程度を超えると結果が32ビット超える。
  95. Show(R);
  96. return 0;
  97.  
  98. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
    1234
X    567
--------
    8638
   7404
  6170
--------
  699678
     1234
X    1001
---------
     1234
  123400
---------
  1235234
       99
X  909090
---------
     8910
   8910
 8910
---------
 89999910
      12345
X     12345
-----------
      61725
     49380
    37035
   24690
  12345
-----------
  152399025