Untitled

 avatar
unknown
c_cpp
2 years ago
335 B
4
Indexable
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
string n,m;
int n1 = 0, m1 = 0;
cin >> n >> m;
for (int i = 0; i < n.length(); i++) {
n1 += (n[n.length()-1-i] - '0') * pow(3,i);
}
for (int i = 0; i < m.length(); i++) {
m1 += (m[m.length()-1-i] - '0') * pow(3,i);
}
cout << m1 + n1;
return 0;
}
Editor is loading...