0%

ACMCoder 2010

ACMCoder2010 水仙花数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <map>
#include <string>
#include <math.h>

using namespace std;



int main(){

freopen("testcase.in", "r", stdin);
freopen("testcase.out", "w", stdout);

int a,b;
while (cin>>a>>b) {
bool flag = false;
for (int i = a; i <= b; ++i) {

int temp = i,result=0;
while (temp) {
result+=pow(temp%10, 3);
temp = temp / 10;
}
if (result == i) {
if (!flag) {
cout<<result;
}else{
cout<<" "<<result;
}
flag = true;
}
}
if (!flag) {
cout<<"no"<<endl;
}else
cout<<endl;
}


fclose(stdin);
fclose(stdout);

return 0;
}