当前位置:网站首页>Daffodils (day 78)
Daffodils (day 78)
2022-07-27 03:40:00 【Zhangxueheng】
List of articles
1: subject
Spring is the season of flowers , Narcissus is one of the most charming representatives , There's a narcissus number in math , It's defined as :
“ Narcissistic number ” A three digit number , The cube sum of its digits is equal to itself , such as :153=13+53+33.
Now it's required to output all the data in m and n The number of daffodils in the range .
Input format
Input contains multiple sets of test data .
Each group of data occupies one row , Contains two integers m and n.
The last line 0 0 End of input .
Output format
Output one line of answers for each group of data , Output from small to large all located in [m,n] The number of daffodils in the range , The numbers are separated by spaces , If not, output no.
Data range
100≤m≤n≤999,
The input can contain at most 10 Group data .
sample input :
100 120
300 380
0 0
sample output :
no
370 371
difficulty : Simple
when / Empty limit :1s / 64MB
Total number of passes :1197
Total attempts :1926
source : Machine test questions for postgraduate entrance examination of Central South University
Algorithm tags
2: Code implementation
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
bool check(int x)
{
int sum = 0, y = x;
while (x)
{
int t = x % 10;
x /= 10;
sum += t * t * t;
}
return sum == y;
}
int main()
{
int m, n;
while (cin >> m >> n, m)
{
int cnt = 0;
for (int i = m; i <= n; i ++ )
if (check(i))
{
cout << i << ' ';
cnt ++ ;
}
if (!cnt) cout << "no";
cout << endl;
}
return 0;
}
边栏推荐
- 若依框架代码生成详解
- 带你了解什么是 Web3.0
- Idea 中添加支持@Data 插件
- MySQL的数据库有关操作
- “满五唯一”和“满二唯一”是什么?有什么不同?
- Duplicate disc: what are the basic attributes of an image? What do you know about images? What are the parameters of the image
- Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial
- flask_restful中reqparse解析器继承
- Quick sequencing and optimization
- The function and application of lpci-252 universal PCI interface can card
猜你喜欢

深入理解Mysql索引底层数据结构与算法

How to interact with the server when the client sends an SQL message

Pytorch损失函数总结

数据库概论 - MySQL的简单介绍

How many implementation postures of delay queue? Daily essential skills!

mysql底层数据结构

$128million! IQM, a Finnish quantum computing company, was supported by the world fund

Detailed explanation of const usage in C language

Annotation summary of differences between @autowired and @resource

Quick sequencing and optimization
随机推荐
The function and application of lpci-252 universal PCI interface can card
[learn FPGA programming from scratch -54]: high level chapter - FPGA development based on IP core - principle and configuration of PLL PLL IP core (Altera)
$128million! IQM, a Finnish quantum computing company, was supported by the world fund
Add support for @data add-on in idea
How to uniquely identify a user SQL in Youxuan database cluster
The diagram of user login verification process is well written!
J-3-point practice in the second game of 2022 Niuke multi school
Graphic SQL, this is too vivid!
Member array and pointer in banyan loan C language structure
Banyan loan,
What are "full five unique" and "full two unique"? Any difference?
How to conduct 360 assessment
Typescript TS basic knowledge interface, generics
Double disk: the main differences between DFS and BFS, the differences in ideology, and the differences in code implementation
Sqlserver select * can you exclude a field
[learning notes, dog learning C] string + memory function
【树链剖分】模板题
docker 创建mysql 8.x容器,支持mac ,arm架构芯片
[tree chain dissection] template question
MySQL中文失败问题