[洛谷P1149]([P1149 NOIP2008 提高组] 火柴棒等式 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn))
public class P1149 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
search(scanner.nextInt());
}
public static void search(int n) {// 先写框架后补函数
int sum = 0;
for (int a = 0; a <= 720; a++) {
for (int b = 0; b <= 720; b++) {
if (f(a) + f(b) + f(a + b) == n - 4) {
sum++;
}
}
}
System.out.println(sum);
}
public static int f(int n) {
if (n == 0) {
return 6;
}
int sum = 0;
int[] a = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
while (n != 0) {// 数位拆分
sum += a[n % 10];
n /= 10;
}
return sum;
}
}
标签:洛谷,scanner,int,static,P1149,public
From: https://www.cnblogs.com/ChuenSan/p/17153714.html