案例可能有多组。对于每个测试案例输入为一行,正整数n,(n<100)
对于每个测试案例输出一行,输出小于等于n的与7无关的正整数的平方和。
链接:https://www.nowcoder.com/questionTerminal/776d401bf86d446fa783f0bef7d3c096 来源:牛客网 import java.util.*; public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int n = reader.nextInt(); int sum = 0; for (int i = 0; i <= n; ++i) { if ((i >= 7 && i % 7 == 0) || i % 10 == 7 || i / 10 == 7) { continue; } sum += i*i; } System.out.println(sum); } }
原文:https://www.cnblogs.com/JAYPARK/p/10181878.html