题目描述
192这个数很厉害,用它分别乘以1、2、3,会得到:
192 x 1 = 192
192 x 2 = 384
192 x 3 = 576
把这三个乘积连起来,得到192384576,正好是一个1~9的全排列
按字典序输出所有的k,满足k是1~9的全排列
输出
每个k占一行
#include<bits/stdc++.h>
using namespace std;
int main() {
for (int x = 123; 3 * x <= 987; x++) {
int y = 2 * x;
int z = 3 * x;
ostringstream oss;
oss << x << y << z;
string s = oss.str();
sort(s.begin(), s.end());
if (s == "123456789") {
cout << x << y << z << endl;
}
}
return 0;
}