Arrays.sort(a); while (q-- > 0) { int x = in.nextInt(); int y = in.nextInt(); int sum1 = n / x; int sum2 = n / y; Set<Integer> set1 = new HashSet<>(); Set<Integer> set2 = new HashSet<>(); for (int i = 1; i <= sum1; i++) { set1.add(i * x); } for (int i = 1; i <= sum2; i++) { if (set1.contains(i * y)) { set1.remove(i * y); } else { set2.add(i * y); } } int count=0; for(int i=0;i<set1.size();i++){ count+=a[n-1-i]; } for(int i=0;i<set2.size();i++){ count-=a[i]; } 第四题这个为什么不对啊,举几个用例都是对的,但是通过0
点赞 评论

相关推荐

2025-12-22 15:25
南京工业大学 运营
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务