CPP
cpp
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
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long a, b;
cin >> a >> b;
cout << a << "\n" << b << endl;
//half of a's order of magnitude
float ashift = pow(10, (floor(log10(a))+1)/2);
//digits in right half of a
float amod = a%(long)ashift;
//b's order of magnitude
float bshift = pow(10, floor(log10(b)) + 1)
/* Assemble the pieces:
1. Remove the lower half of digits in a.
2. Shift a leftward by number of digits in b.
3. Add b shifted by half of a's magnitude
4. Add back in the lower half of a.
*/
cout << (long)((a - amod)*bshift + b*ashift + amod << endl;
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run