#include <iostream>
#include <cmath>
#include <list>
std::size_t CountDidit(int N){
std::size_t i=0;
while (N != 0){
i++;
N /= 10;
}
return i;
}
int SnipeDigit(int N, int P){
int A = std::pow(10, P);
int B = N / A;
int C = (N / (A * 10)) * 10;
return B - C;
}
int Sign(int N){
return N >= 0 ? 1:-1;
}
int MakeHoge(int N){
std::list<int> L;
int Count = CountDidit(N);
int V = 0;
int ret = 0;
for (int i = 0; i < Count; i++){
V = SnipeDigit(N, i);
if (V != 0)L.push_front(V);
}
int S = L.size();
for (int i = 0; i < Count - S; i++){
L.push_back(0);
}
for (auto i : L){
ret = (ret * 10) + std::abs(i);
}
return ret*Sign(N);
}
int main(){
int V = 123456789;
int V2 = 1020304050;
int p = V2;
int N = MakeHoge(p);
std::cout << p << "=" << N << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxsaXN0PgoKc3RkOjpzaXplX3QgQ291bnREaWRpdChpbnQgTil7CglzdGQ6OnNpemVfdCBpPTA7CgoJd2hpbGUgKE4gIT0gMCl7CgkJaSsrOwoJCU4gLz0gMTA7Cgl9CgoJcmV0dXJuIGk7Cn0KCmludCBTbmlwZURpZ2l0KGludCBOLCBpbnQgUCl7CglpbnQgQSA9IHN0ZDo6cG93KDEwLCBQKTsKCWludCBCID0gTiAvIEE7CglpbnQgQyA9IChOIC8gKEEgKiAxMCkpICogMTA7CgoJcmV0dXJuIEIgLSBDOwp9CgppbnQgU2lnbihpbnQgTil7CglyZXR1cm4gTiA+PSAwID8gMTotMTsKfQoKaW50IE1ha2VIb2dlKGludCBOKXsKCXN0ZDo6bGlzdDxpbnQ+IEw7CgoJaW50IENvdW50ID0gQ291bnREaWRpdChOKTsKCWludCBWID0gMDsKCWludCByZXQgPSAwOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBDb3VudDsgaSsrKXsKCQlWID0gU25pcGVEaWdpdChOLCBpKTsKCQlpZiAoViAhPSAwKU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