第三题100 Scanner s = new Scanner(System.in); int n = s.nextInt(); BigInteger[] a = new BigInteger[n]; for(int i = 0;i < n;i ++) a[i] = new BigInteger(s.next()); BigInteger sum = new BigInteger("0"); BigInteger cur = a[0]; BigInteger pre = a[0]; for(int i = 1;i < n;i ++) { sum = sum.add(cur.multiply(a[i])); pre = pre.add(a[i]); cur = cur.add(pre); } System.out.println(sum.mod(new BigInteger("1000000007")));
4 13

相关推荐

09-30 09:15
中小 C++
投递东软集团等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客企业服务