Hangzhou Electric 2010 (Number of daffodils)
Number of daffodils
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 123522 Accepted Submission (s): 36609
problem DescriptionSpring is the season of flowers, Narcissus is one of the most charming representatives, mathematics has a number of daffodils, he is defined as:
"Narcissus number" refers to a three-digit number, its number of cubes and equal to itself, such as: 153=1^3+5^3+3^3.
It is now required to output all the number of daffodils in the M and N ranges.
InputThere are multiple groups of input data, one row for each group, including two integers m and n (100<=m<=n<=999).
Outputfor each test instance, it is required to output all the number of daffodils in a given range, that is, the output of daffodils must be greater than or equal to M, and less than or equal to N, if there are multiple, then the order from small to large lines in the output, separated by a space;
if the number of daffodils does not exist within the given range, the output is no;
the output for each test instance takes one row.
Sample Input About380Sample OutputNo370 371AuthorLCY SourceC language Programming exercises (II.) recommendjgshiningTopic Description: In a given interval, to meet the problem conditions (Narcissus number) output!
1#include <cstdio>2#include <iostream>3#include <cmath>4 using namespacestd;5 BOOLSXH (intN)6 {7 intK,r =0, M =N;8 9 while(N >0 )Ten { OneK = n%Ten; AR + = k*k*K; -N/=Ten; - } the returnr = =m; - } - intMain () - { + BOOLFlag; - intx, y, I; + while(cin>>x>>y) A { atFlag =0; - for(i=x; i<=y; + +)i) - { - if(Sxh (i)) - { - if(flag) in { -cout<<" "; to } +Flag =1; -cout<<i; the } * } $ if(Flag = =0 )Panax Notoginseng { -cout<<"No"; the } +cout<<Endl; A } the return 0; +}
View Code
Written test questions