解题思路:
注意事项:小心啦
参考代码:
#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 人评分
C语言训练-字符串正反连接 (C语言代码)浏览:622 |
C语言训练-素数问题 (C语言代码)浏览:1662 |
【排队买票】 (C语言代码)浏览:900 |
WU-蓝桥杯算法提高VIP-交换Easy (C++代码)浏览:1119 |
【金明的预算方案】 (C++代码)浏览:940 |
【金明的预算方案】 (C++代码)浏览:843 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:559 |
出圈】指针malloc版浏览:355 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:691 |
一元一次方程 (C语言代码)浏览:4075 |