#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <tuple>
typedef std::vector<std::tuple<std::uint64_t, std::uint64_t, std::uint64_t>> RType;
typedef std::vector<std::uint64_t> DType;
DType SepDigit(std::uint64_t N){
std::uint64_t V = 0;
DType R;
std::uint64_t Radix = 10;
while (N != 0){
V = N % Radix;
N /= Radix;
R.push_back(V);
}
return R;
}
RType MakeHoge(){
DType Ns{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
std::uint64_t A = 0, B = 0;
std::uint64_t Ans = 0, C = 0;
DType T;
bool F = true;
RType R;
//std::uint64_t TT = 0;
do{
A = Ns[0] + (Ns[1] * 10) + (Ns[2] * 100) + (Ns[3] * 1000);
B = Ns[4] + (Ns[5] * 10) + (Ns[6] * 100) + (Ns[7] * 1000);
Ans = A*B;
T = SepDigit(Ans);
F = true;
for (std::size_t i = 0; i < T.size(); i++){
if (T[i] == Ns[8]) continue;
if (T[i] == Ns[9]) continue;
F = false;
break;
}
if (F == true){
R.push_back(std::make_tuple(A, B, Ans));
//std::cout << A <<"*"<< B <<"="<< Ans << std::endl;
}
//std::cout << TT++ << "\r";
} while (std::next_permutation(Ns.begin(), Ns.end()));
//std::cout << std::endl;
return R;
}
bool Show(RType& R){
for (auto& o : R){
std::cout << std::get<0>(o) <<"*"<< std::get<1>(o) <<"="<< std::get<2>(o) << std::endl;
}
return true;
}
int main(){
auto R = MakeHoge();
Show(R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0ZGludD4KI2luY2x1ZGUgPHR1cGxlPgoKdHlwZWRlZiBzdGQ6OnZlY3RvcjxzdGQ6OnR1cGxlPHN0ZDo6dWludDY0X3QsIHN0ZDo6dWludDY0X3QsIHN0ZDo6dWludDY0X3Q+PiBSVHlwZTsKdHlwZWRlZiBzdGQ6OnZlY3RvcjxzdGQ6OnVpbnQ2N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