package com.meituan.online; import java.util.*; /** * Created by bruceguo on 2017/9/14. */ public class Problem1 { private static Set<Long> resultSets = new HashSet<>(); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] nums = new int[n]; for (int i = 0; i < n; i++) { nums[i] = scanner.nextInt(); } int sum = 0; for (int i = 0; i < nums.length; i++) { for (int j = i + 1; j < nums.length; j++) { process(nums[i], nums[j]); } } System.out.println(resultSets.size()); } private static void process(int n1, int n2) { long result = 0; //n1前,n2后 result = n2 + n1 * (int) Math.pow(10, (String.valueOf(n2).length())); if (result % 7 == 0) { resultSets.add(result); } //n1后,n2前 result = n1 + n2 * (int) Math.pow(10, (String.valueOf(n1).length())); if (result % 7 == 0) { resultSets.add(result); } } } 就想问为什么AC总是10%!!!输入没有用while循环的原因???
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务