// 黑白棋 public class Main_360_2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int q = sc.nextInt(); sc.nextLine(); int[][] operation = new int[q][2]; int i = 0; while(i < q){ operation[i][0] = sc.nextInt(); operation[i][1] = sc.nextInt(); sc.nextLine(); i++; } boolean[] flag = new boolean[num]; for (int j = 0; j < num; j++) { flag[j] = false; } for (int j = 0; j < q; j++) { int sum = 0; for (int k = operation[j][0]-1; k < operation[j][1]; k++) { flag[k] = !flag[k]; } for (int k = 0; k < num; k++) { if(!flag[k]){ sum++; } } System.out.println(sum); } } }
点赞 评论

相关推荐

想run的马里奥在学...:这个学历帮你扫平百分之80的障碍,投就完了,这会找不到就等3月暑期一样能找到
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务