#include <iostream> #include <map> #include <vector> using namespace std; string fun(char first) { int n = first - '0'; if (n < 2) { return "2"; } else if (n == 2) { return "3"; } else if (n == 3) { return "5"; } else if (n < 6) { return "7"; } else { return "11"; } } int main() { int t; cin >> t; string x; while (cin >> x) { // 根据 x 的首位得到质数,x 的剩余位数补 0 string res(x.size() - 1, '0'); cout << fun(x[0]) << res << endl; } } // 64 位输出请用 printf("%lld")
例 1:12345
解:x[0] = 1, (x[0]~2x[0]] = (1, 2],其中有质数 2 ,补 4 个 0,结果:20000;
例 2:766
解:x[0] = 7, x[0]~2x[0] = (7, 14],其中有质数 11 ,补 2 个 0,结果:1100;