可以帮我看一下我第一题的代码问题在哪吗,我卡在16.67不动了 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 int n = in.nextInt(); int mat[] = new int[n]; for(int i = 0;i < n;i++){ mat[i] = in.nextInt(); } if(n <= 2) System.out.print(0); else{ int ans = 0; int ou = 0; int ji = 0; for(int i = 2;i < n;i++){ if(mat[i-2] % 2 == 0) ou++; else if(mat[i-2] % 2 == 1) ji++; if(mat[i] % 2 == 0) ans += ou; else if(mat[i] % 2 == 1) ans += ji; } System.out.print(ans); } } }
点赞 1

相关推荐

不愿透露姓名的神秘牛友
今天 14:10
点赞 评论 收藏
分享
05-16 11:16
已编辑
东华理工大学 Java
牛客73769814...:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
牛客创作赏金赛
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务