解题思路:
注意事项:小心啦
参考代码:
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>
using namespace std;
long n;
int counts;
int a[10],b[10];
long get(int s, int e){
long t = 0;
for(int i=s; i<e; i++)
t = t*10 + a[i];
return t;
}
void fun(){
for(int i=1; i<=7; i++){
long t1 = get(0,i);
for(int j=i+1; j<9; j++){
long t2 = get(i,j);
long t3 = get(j,9);
if(n == t1 + t2/t3 && t2%t3==0)
counts++;
}
}
}
void dfs(int k){
if(k == 9){
fun();
return;
}
for(int i=0; i<9; i++)
if(b[i]==0){
b[i] = 1;
a[k] = i+1;
dfs(k+1);
b[i] = 0;
}
}
int main(){
cin>>n;
dfs(0);
cout<<counts<<endl;
return 0;
}
0.0分
0 人评分
A+B for Input-Output Practice (III) (C语言代码)浏览:576 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:632 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:660 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:565 |
图形输出 (C语言代码)浏览:1387 |
1054题解浏览:467 |
1051(奇了怪了)浏览:649 |
Tom数 (C语言代码)浏览:555 |
陶陶摘苹果2 (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:470 |