import java.util.Scanner; public class selfConservation { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int M = scan.nextInt(); int K[] = new int[M]; for (int i = 0; i < M; i++) { K[i] = scan.nextInt(); } /*for(int i=0;i<K.length;i++) { System.out.println(K[i]); }*/ for (int i = 0; i < K.length; i++) { if (K[i] < 10) { int search=0; for (int N = 0; N < 10; N++) { if (K[i] * K[i] * N % 10 == K[i]) { System.out.println(N + " " + N * K[i] * K[i]); search=1; break; } } if (search==0){ System.out.println("No"); } } else if (K[i] < 100) { int search=0; for (int N = 0; N < 10; N++) { if (K[i] * K[i] * N % 100 == K[i]) { System.out.println(N + " " + N * K[i] * K[i]); search=1; break; } } if (search==0){ System.out.println("No"); } } else { int search=0; for (int N = 0; N < 10; N++) { if (K[i] * K[i] * N % 1000 == K[i]) { System.out.println(N + " " + N * K[i] * K[i]); search=1; break; } } if (search==0){ System.out.println("No"); } } } } }
原文地址:https://www.cnblogs.com/xianghaoran/p/12347240.html
时间: 2024-10-09 01:38:10