幽灵特工 @ 2020-07-31 18:05:19
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b, int c, int n) {
if (a % n == 0 && b % n == 0 && c % n == 0) {
return n;
}
else {
n--;
gcd(a, b, c, n);
}
}
int main()
{
int A, B, C;
cin >> A >> B >> C;
int n = min(A, min(B, C));
n = gcd(A, B, C, n);
A /= n;
B /= n;
C /= n;
int f=0;
for (int i = 123; i < 985; i++) {
int a = i * A;
int b = i * B;
int c = i * C;
if (100 < a && a < 999 && 100 < b && b < 999 && 100 < c && c < 999) {
int l[9];
l[0] = a / 100;
l[1] = (a % 100) / 10;
l[2] = (a % 10);
l[3] = b / 100;
l[4] = (b % 100) / 10;
l[5] = b % 10;
l[6] = c / 100;
l[7] = (c % 100) / 10;
l[8] = c % 10;
int sum = 0;
int s = 1;
for (int k = 0; k < 9; k++) {
sum += l[k];
s *= l[k];
}
if (sum == 45 && s == 362880) {
cout << a << " " << b << " " << c << " " << endl;
f = 1;
}
}
}
if (f == 0) {
cout << "No!!!" << endl;
}
}
by 幽灵特工 @ 2020-07-31 18:05:31
求 应该如何改进
by Dimly_dust @ 2020-07-31 18:09:52
暴力判个等试试?
by IceYukino @ 2020-07-31 18:10:52
@幽灵特工 为什么i要从123开始?
by IceYukino @ 2020-07-31 18:10:58
@幽灵特工 从1开始啊
by 冰糖鸽子 @ 2020-07-31 18:13:40
@gqh_蒟蒻_or_大佬
??为什么
by IceYukino @ 2020-07-31 18:14:04
@demonred 为什么从123开始?
by Dimly_dust @ 2020-07-31 18:14:08
@gqh_蒟蒻_or_大佬 a最小是123。。。没有必要更改
by 冰糖鸽子 @ 2020-07-31 18:14:27
@gqh_蒟蒻_or_大佬
您怎么想的?
by IceYukino @ 2020-07-31 18:14:28
问你们个事情
by IceYukino @ 2020-07-31 18:14:41
123:456:789能化简吗?