-
Notifications
You must be signed in to change notification settings - Fork 1
/
LQB-凑算式.cpp
67 lines (64 loc) · 1.08 KB
/
LQB-凑算式.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<iostream>
#include<cstring>
using namespace std;
int count=0;
void judge(int arr[], int a, int b, int c){
for(int i=123; i<=987; i++){
int flag = true;
int x=i;
while(x){
int index = x % 10;
if(index == 0 || arr[index] > 0){
flag = false;
break;
}
else{
arr[x%10]++;
x/=10;
}
}
if(flag){
for(int j=123; j<=987; j++){
int y=j;
bool flag1 = true;
while(y){
int index = y % 10;
if(index == 0 || arr[index] > 0){
flag1 = false;
break;
}
else{
arr[y%10]++;
y/=10;
}
}
if(flag1){
double v = 1.0 * (b * j + c * i) / (j * c);
if(10-a == v){
count++;
cout << a << " " << b << " " << c << " " << i << " " << j << endl;
}
}
}
}
}
}
int main(){
for(int i=1; i<=9; i++){
for(int j=1; j<=9; j++){
if(i == j)
continue;
for(int k=1; k<=9; k++){
if(j == k || i == k)
continue;
int arr[10];
memset(arr, 0, sizeof(int) * 10);
arr[i]++;
arr[j]++;
arr[k]++;
judge(arr, i, j, k);
}
}
}
cout << count << endl;
}