You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
597 B

2 years ago
#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;
}