该秒题了
2026-09-01 19:49:01
发布于:广东
1阅读
0回复
0点赞
五重循环妙解
#include <iostream>
using namespace std;
int main() {
int count = 0;
for (int a = 1; a <= 9; a++)
for (int b = 1; b <= 9; b++) {
if (b == a) continue;
for (int c = 1; c <= 9; c++) {
if (c == a || c == b) continue;
for (int d = 1; d <= 9; d++) {
if (d == a || d == b || d == c) continue;
for (int e = 1; e <= 9; e++) {
if (e == a || e == b || e == c || e == d) continue;
int ab = a * 10 + b;
int cde = c * 100 + d * 10 + e;
int adb = a * 100 + d * 10 + b;
int ce = c * 10 + e;
if (ab * cde == adb * ce){
cout << ab << cde << "\n";
count++;
}
}
}
}
}
cout << count << endl;
return 0;
}
//E E E E E E A S S S Y Y
//E A A S Y Y
//E E E E E A A A A A S S Y Y
//E A A S Y
//E E E E E E A A S S S Y
这里空空如也







有帮助,赞一个