第一题
package ccf201612; import java.util.Scanner; public class p1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int res = -1; for (int i = 0; i < n; i++) { int max = 0; int min = 0; for (int j = 0; j < n; j++) { if (a[j] != a[i]) { if (a[j] > a[i]) { max++; } else if (a[j] < a[i]) { min++; } } } if (max == min) { res = a[i]; } } System.out.println(res); } }
第二题
package ccf201612; import java.util.Scanner; public class p2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); double S = 0; if (T <= 3500) { S = T; } else if (T <= 4955) { S = (T - 3500) / (1 - 0.03) + 3500; } else if (T <= 7655) { S = (T - 4955) / (1 - 0.1) + 5000; } else if (T <= 11255) { S = (T - 7655) / (1 - 0.2) + 8000; } else if (T <= 30755) { S = (T - 11255) / (1 - 0.25) + 12500; } else if (T <= 44755) { S = (T - 30755) / (1 - 0.3) + 38500; } else if (T <= 61005) { S = (T - 44755) / (1 - 0.35) + 58500; } else { S = (T - 61005) / (1 - 0.45) + 83500; } int res = (int) S; System.out.println(res); } }