类似填空题:
①算式900:
https://blog.csdn.net/s44Sc21/article/details/132746513?spm=1001.2014.3001.5501https://blog.csdn.net/s44Sc21/article/details/132746513?spm=1001.2014.3001.5501
②九宫幻方③七星填数④幻方填空:
https://blog.csdn.net/s44Sc21/article/details/132429826?spm=1001.2014.3001.5501https://blog.csdn.net/s44Sc21/article/details/132429826?spm=1001.2014.3001.5501
⑤纸牌三角形:
https://blog.csdn.net/s44Sc21/article/details/132784482?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22132784482%22%2C%22source%22%3A%22s44Sc21%22%7Dhttps://blog.csdn.net/s44Sc21/article/details/132784482?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22132784482%22%2C%22source%22%3A%22s44Sc21%22%7D
⑥搭积木:
https://blog.csdn.net/s44Sc21/article/details/132840321?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22132840321%22%2C%22source%22%3A%22s44Sc21%22%7Dhttps://blog.csdn.net/s44Sc21/article/details/132840321?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22132840321%22%2C%22source%22%3A%22s44Sc21%22%7D⑦五星填数:
https://blog.csdn.net/s44Sc21/article/details/132839777?spm=1001.2014.3001.5502https://blog.csdn.net/s44Sc21/article/details/132839777?spm=1001.2014.3001.5502
题目描述
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
B DEF
A + --- + ------- = 10C GHI
这个算式中 A ~ I 代表 0 ~ 9 的数字,不同的字母代表不同的数字。
比如: 6+8/3+952/714 就是一种解法,5+3/1+972/486 是另一种解法。
这个算式一共有多少种解法?
运行限制
- 最大运行时间:1s
- 最大运行内存: 128M
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改public class Main {static int[] a=new int[9];static int[] biaoji=new int[10];static int ans=0;static int flag=0;public static void main(String[] args) {Scanner scan = new Scanner(System.in);//在此输入您的代码...scan.close();dfs(0);System.out.println(ans);}public static void dfs(int n){if(n==9){int A=a[0];int B=a[1];int C=a[2];int D=a[3]*100+a[4]*10+a[5];int E=a[6]*100+a[7]*10+a[8];if((A+B*1.0/+C+D*1.0/E)==10){ans++;return;}else{return;}}if(a[n]!=0){dfs(n+1);}for(int i=1;i<=9;i++){if(biaoji[i]==0&&a[n]==0){biaoji[i]=1;a[n]=i;dfs(n+1);biaoji[i]=0;a[n]=0;}}}
}