当前位置:网站首页>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 
边栏推荐
- C语言实现安全性极高的游戏存档并读档
- Requirements design document and the changing role of the product manager
- The 2nd Shanxi Province Network Security Skills Competition (Enterprise Group) Partial WP (10)
- ms project2010项目管理软件使用技巧总结
- LeetCode Algorithm 328. 奇偶链表
- 美国再次加息75个基点 陷入“技术性衰退”?加密市场却呈现复苏力量
- 22. Why do you need a message queue?What are the advantages of using the message queue?
- 5. View parsing and template engine
- The Double Pointer Problem (Part 1)
- Building and sharing the root of the digital world: Alibaba Cloud builds a comprehensive cloud-native open source ecosystem
猜你喜欢

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

1. Get data - requests.get()

Discourse Custom Header Links

Simulation problem (middle)

webService interface

nSoftware.PowerShell.Server.2020

Chapter8 Support Vector Machines

See you in shenzhen!Cloud native to accelerate the application building special: see cloud native FinOps, SRE, high-performance computing scenario best practices

Whole process scheduling - Azkaban entry and advanced

WPF introduces ttf icon file usage record
随机推荐
解决go环境编译不了exe
Whole process scheduling - Azkaban entry and advanced
Plan for many situations in the processing chain
Machine Learning: Knowing the Dimensionality Reduction Process Through Low Variance Filtering
Simple experiment with BGP
L2-020 功夫传人
模拟问题(上)
Excellent MySQL interview questions, 99% must ask in preparation for August!I can't pass the interview
mysql isolation level
四、Web开发
(Problem practice) Conditional probability + weight line segment tree + FWT + suffix array
[Vitis] Code implementation of ZCU102 development board PS-side control PL-side reset
3. Dependency configuration management
Some understanding of YOLOv7
六、读取应用配置+日志配置
DLL description (1)
go语言学习笔记四
LeetCode Algorithm 2326. Spiral Matrix IV
(RCE) Remote Code/Command Execution Vulnerability Vulnerability Exercise
POJ1321 chessboard problem (detailed explanation)