当前位置:网站首页>Acwing perfect number
Acwing perfect number
2022-07-30 05:02:00 【Little W】
Title description:
A whole number is called a perfect number if the sum of all its divisors except itself is equal to that number.
For example, 66 is a perfect number because the sum of its divisors other than itself is 1+2+3=61+2+3=6.
Now, given your NN integers, please determine whether these numbers are perfect in turn.
Input format:
The first line contains the integer NN, indicating a total of NN test cases.
The next NN lines, each containing an integer XX that requires your judgment.
Output format:
Output one result per test case, one line per result.
If the test data is perfect, output X is perfect, where XX is the test data.
If the test data is not perfect, output X is not perfect, where XX is the test data.
Data range:
1≤N≤1001≤N≤100,
1≤X≤1081≤X≤108
Sample input:
36528Sample output:
6 is perfect5 is not perfect28 is perfectAnalysis:
This question itself is not difficult, and it can be done in double loops, but when a number is very large, the time will exceed the time limit. At this time, we must think about the optimization method: this is the test of mathematics, if a isA divisor of b, then b/a is also a divisor of b.For example: 2 is a divisor of 12, and 6 is also a divisor of 12.We only need to enumerate from 1 to b/a, that is, a*a This is the result: (obviously) Let's take a look at the optimized: Pass!#include 
#include 
边栏推荐
- ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
- 模拟问题(中)
- Weight line segment tree + line segment tree split/merge + CF1659D
- 全流程调度——Azkaban入门与进阶
- Simple experiment with BGP
- Learning of redis_Basic part
- 美国再次加息75个基点 陷入“技术性衰退”?加密市场却呈现复苏力量
- Protobuf compound data types, speaking, reading and writing
- 涂鸦Wi-Fi&BLE SoC开发幻彩灯带
- go language study notes 2
猜你喜欢

Acwing完全数
Go study notes (84) - Go project directory structure

Golang channel implementation principle

如何与墨西哥大众VW Mexico建立EDI连接

Unity beginner 5 cameras follow, border control and simple particle control (2 d)

解决报错SyntaxError: (unicode error) ‘utf-8‘ codec can‘t decode byte 0xb7 in position 0: invalid start b

Dynamic Programming Problems (End)

webService interface

2.6 Radix sort (bucket sort)

KubeMeet Registration | The complete agenda of the "Edge Native" Online Technology Salon has been announced!
随机推荐
Catch That Cow (detailed)
Become a qualified cybersecurity, do you know this?
ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
Discourse 自定义头部链接(Custom Header Links)
22. 为什么需要消息队列?使用消息队列有什么好处?
DAY17, CSRF vulnerability
小程序npm包--API Promise化
1. Get data - requests.get()
Stimulsoft ReportsJS and DashboardsJS. 2022.3.3
Small programs use npm packages to customize global styles
KubeMeet Registration | The complete agenda of the "Edge Native" Online Technology Salon has been announced!
Go study notes (84) - Go project directory structure
A must see for software testers!Database knowledge MySQL query statement Daquan
Get the local IP and Request's IP
2.6 Merge Sort
小程序使用npm包定制全局样式
VisualStudio2022本地调试进入特别慢问题解决
Using the GPU parallel computing 】 【 OpenCL&OpenCLUtilty GPU parallel computing
2.4 hill sorting
Solve the go environment can not compile exe