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

27 lines
597 B
C++
Raw 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;
const int N = 10010;
int b[N];
void MeiGuiShu() {
// 枚举出所有4位数的玫瑰花数,利用桶进行保存
for (int i = 1000; i <= 9999; i++) {
int x = i, sum = 0;
while (x) {
int a = x % 10;
x /= 10;
sum += a * a * a * a;
}
if (sum == i) b[i] = 1;
}
}
int main() {
// 标识玫瑰数
MeiGuiShu();
int n, m;
cin >> n >> m;
for (int i = n; i <= min(m, 9999); i++)
if (b[i]) cout << i << endl;
return 0;
}