Files
python/TangDou/LuoGuBook/P1618_Next_Permutation.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
823 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[10];
/**
总结STL中的全排列函数框架
do {
} while (next_permutation(a + 1, a + 10));
1、只能配合数组使用
2、注意范围是前闭后开。
3、效果是可以所有可能出现的全排列
*/
int main() {
LL A, B, C, x, y, z, cnt = 0;
cin >> A >> B >> C;
for (int i = 1; i <= 9; i++) a[i] = i;
do {
x = a[1] * 100 + a[2] * 10 + a[3];
y = a[4] * 100 + a[5] * 10 + a[6];
z = a[7] * 100 + a[8] * 10 + a[9];
if (x * B == y * A && y * C == z * B) //避免除法防止爆long long
printf("%lld %lld %lld\n", x, y, z), cnt++;
} while (next_permutation(a + 1, a + 10));
if (!cnt)printf("No!!!");
return 0;
}