题目:https://pintia.cn/problem-sets/994805260223102976/problems/1071785664454127616
代码
#include<cmath>#include<string>#include<iostream>#include<cstdio>using namespace std;int main(){int m, k;scanf("%d", &m);for(int i = 0; i < m; i++){scanf("%d", &k);int flag = 0;for(int n = 1; n < 10; n++){int temp = n * k * k;string temp_str = to_string((long long)temp), temp_k = to_string((long long)k);if(temp_str.substr(temp_str.size() - temp_k.size()) == temp_k){printf("%d %d\n", n, temp);flag = 1;break;}}if(flag == 0) printf("No\n");}return 0;}
