用例过了百分之四十,请问问题出在哪里,麻烦了

import java.util.Scanner; public class Main { public static void main(String[] args){
        Scanner in=new Scanner(System.in);  int n=in.nextInt();//格子个数  int m=in.nextInt();//颜色种类  int []numbers=new int[n];  int []colors=new int[n];  long result=0;  for(int i=0;i<n;i++){
            numbers[i]=in.nextInt();  } for(int mm=0;mm<n;mm++){
            colors[mm]=in.nextInt();  } for(int j=0;j<n;j++){ for(int h=1;h<=(n-1-j)/2;h++){ if(colors[j]==colors[j+2*h]){
                    result=(result+(j+j+2*h+2)*(numbers[j]+numbers[j+2*h]))%10007;   }

            }
        }
        System.out.println(result);  }
}


全部评论
+1,溢出了
4 回复
分享
发布于 2020-12-09 10:56
数据溢出了,要开long long
点赞 回复
分享
发布于 2020-12-08 22:10
联易融
校招火热招聘中
官网直投

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务