HDACM 1406
直接打表解决
import java.util.Scanner;public class Main{
public static void main(String[] args) {boolean finish[] = new boolean[10000];for (int i = 1; i < finish.length; i++) {int sum = 1;for (int j = 2; j*j <= i; j++) {if (i%j==0) {sum += j+i/j;}}if (sum == i) {finish[i] = true;}}Scanner sc = new Scanner(System.in);int n = sc.nextInt();while (n-->0) {int a = sc.nextInt();int b = sc.nextInt();int count = 0;for (int i = a>b?b:a; i <= (a>b?a:b); i++) {if (finish[i]) {count++;}}System.out.println(count);}sc.close();}
}