2 220 284 100 200
YES NO
import java.util.Scanner; public class Main { static int getSum(int temp) { int sum = 0; for (int i = 2; i <= temp / 2; i++) { if (temp % i == 0) { sum += temp % i == i ? i : temp % i + i; } } return sum + 1; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); while (m-- != 0) { int a = scanner.nextInt(); int b = scanner.nextInt(); int sum1 = getSum(a); int sum2 = getSum(b); if (sum1 == b && sum2 == a) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
原文地址:http://blog.csdn.net/u011506951/article/details/24578853