define _CRT_SECURE_NO_WARNI NGS include fstream include iostream inclu

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
string perest(string s)
{
for (int i = 0; i<(s.length() / 2); i++) {
char tmp = s[i];
s[i] = s[s.length()- i - 1];
s[s.length()-i-1] = tmp;
}
return s;
}
int main() {
//freopen ("input.txt","r",stdin);
//freopen ("output.txt","w",stdout);
std::string str2="";
std::string strx;
std::string stry;
std::string str;
cin >> strx;
cin >> stry;
stry = perest(stry);
strx = perest(strx);
for (int q=0; q<stry.length(); q++)
{
std::string str1="";
for (int i = 0; i <strx.length(); i++)
str1 = str1 + "0";
int d = stry[q]-'0';
int c=0;
for (int i=0;i<strx.length(); i++)
{
int a = strx[i]-'0';
if (a*d+c<10)
{
str1[i] = a*d+'0'+c;
c = 0;
}
else {
str1[i]=(((a*d)+c) % 10)+'0';
c = ((a*d)+c)/10;
}
}
char tyu = '0'+c;
if (c>0) str1 =str1+ tyu;
str1 = perest(str1);
for (int u = 0; u<q;u++)
str1= str1+'0';
str1 = perest(str1);
str2 = perest(str2);
if (str1.length() > str2.length())
{
for (int i = str2.length(); i<str1.length();i++)
str2 = str2 + '0';
}
else
{
for (int i = str1.length(); i<str2.length();i++)
str1 = str1 + '0';
}
int n = str1.length();
for (int i = 0; i < n; i++)
str = str + "0";
int a = 0;
int b;
for (int i = 0; i < n; i++)
{
a = a + str1[i] - '0';
b = str2[i] - '0';
if ((a + b) < 10)
{
str[i] = '0' + a + b;
a = 0;
}
else
{
str[i] = '0' + a + b - 10;
a = 1;
}
}
if (a==1)
{str = str + '1';}
str = perest(str);
str2 = str;
}
std::string otvet;
int bcd = 0;
for (int i=0; i<str.length(); i++)
{
if (str[i] != '0' || bcd == 1 )
{otvet = otvet+str[i];
bcd = 1;}
}
if (otvet=="")
otvet = "0";
cout << otvet <<endl;
//cin >> str;
return 0;
}