当前位置:网站首页>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 
边栏推荐
- Become a qualified cybersecurity, do you know this?
- Some understanding of YOLOv7
- VisualStudio2022 local debugging entry is particularly slow problem solving
- 七、自定义配置
- GO语言学习笔记一
- How with Mexico Volkswagen VW EDI connection to Mexico
- (RCE) Remote Code/Command Execution Vulnerability Vulnerability Exercise
- 动态规划问题(完结篇)
- Image stitching (registration) case based on OpenCV
- IGBT wafers used in photovoltaic inverters
猜你喜欢

DAY17, CSRF vulnerability

美国再次加息75个基点 陷入“技术性衰退”?加密市场却呈现复苏力量

Chapter8 Support Vector Machines

Discourse Custom Header Links

ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序

QT(39)-vs development qt program prompts that the source file cannot be opened

小程序使用npm包定制全局样式

Small program npm package--API Promise

七、自定义配置
Go study notes (84) - Go project directory structure
随机推荐
Excellent MySQL interview questions, 99% must ask in preparation for August!I can't pass the interview
gnss rtcm rtklib Ntrip...
Catch That Cow(详解)
模拟问题(上)
The Complete Go Books - Beginner to Advanced and Web Development
Verify that the addShutdownHook hook takes effect
[Linear table] - Detailed explanation of three practice questions of LeetCode
[3D Detection Series-PointRCNN] Reproduces the PointRCNN code, and realizes the visualization of PointRCNN3D target detection, including the download link of pre-training weights (starting from 0 and
C# One Week Introductory "C# - Classes and Objects" Day Six
Dynamic Programming Problems (End)
Predictive maintenance scheduling of multiple power equipment based on data-driven fault prediction
Solve the go environment can not compile exe
QT(39)-vs development qt program prompts that the source file cannot be opened
2.4 hill sorting
Perspective transformation matrix of image perspective correction should be matrix (single)/findHomography with getPerspectiveTransformd difference
Some understanding of YOLOv7
Image stitching (registration) case based on OpenCV
See you in shenzhen!Cloud native to accelerate the application building special: see cloud native FinOps, SRE, high-performance computing scenario best practices
Mini Program wx.miniProgram.navigateTo jump address cannot be tabbar address
L2-020 功夫传人