度小满笔试
第一题
public class duxiaoman_01 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()){ int n = in.nextInt(); int k = in.nextInt(); int[] nums = new int[n]; for(int i=0; i<n; i++){ nums[i] = in.nextInt(); } int res = 0; for(int i=0; i<n; i++){ int max = -1; int min = 1000000001; for(int j=i; j<n; j++){ max = Math.max(max, nums[j]); min = Math.min(min, nums[j]); if(max == k * min){ res ++; } } } System.out.println(res); } } }
public class duxiaoman_02 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()){ int T = in.nextInt(); for(int time=0; time<T; time++){ int n = in.nextInt(); int m = in.nextInt(); int k = in.nextInt(); int x = in.nextInt(); int[][] map = new int[n][m]; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ map[i][j] = in.nextInt(); } } boolean temp = helper(map, x, 0, 0); if(!temp){ System.out.println("no"); }else{ System.out.println("yes"); } } } } private static boolean helper(int[][] map, long sum, int x, int y){ if(x == map.length-1 && y == map[0].length-1 && sum == map[x][y]){ return true; } sum -= map[x][y]; if(x+1 < map.length && helper(map, sum, x+1, y)){ return true; } if(y+1 < map[0].length && helper(map, sum, x, y+1)){ return true; } return false; } }
public class duxiaoman_030 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()){ int n = in.nextInt(); long mod = 1000000007; if(n == 1){ System.out.println("9"); }else if(n == 2){ System.out.println("80"); }else{ long[] dp0 = new long[n+1]; long[] dp1 = new long[n+1]; dp0[1] = 8; dp0[2] = 72; dp1[1] = 1; dp1[2] = 8; for(int i=3; i<=n; i++){ dp0[i] = 8 * (dp0[i-1] + dp1[i-1]); dp1[i] = dp0[i-2] * 8; if(dp0[i] > mod && dp1[i] > mod){ dp0[i] = dp0[i] % mod; dp1[i] = dp1[i] % mod; } } long res = (dp0[n] + dp1[n]) % mod; System.out.println(res); } } } }