当前位置:网站首页>-完全数-
-完全数-
2022-08-03 05:10:00 【-JMY-】
题目描述
求2~n之间的所有完全数;完全数是指该数的所有因数(除了本身)之和等于原数,如6=1+2+3
输入
一个正整数n
输出
n以内所有的完全数,每个数之间用空格隔开。
样例输入
7
样例输出
6
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,s;
cin>>n;
for(int i=2;i<=n;i++){
s=0;
for(int j=1;j<i;j++){
if(i%j==0)
s+=j;
}
if(s==i)
cout<<i<<' ';
}
}
边栏推荐
- The problem that the rosbag tool plotjuggler cannot open rosbag
- typescript39-class类的可见修饰符
- typescript45-接口之间的兼容性
- Gradle的安装配置
- Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
- OptionError: ‘Pattern matched multiple keys‘
- Coordinate knowledge in digital twin campus scenarios
- typescript41-class类的私有修饰符
- 【 Harmony OS 】 【 ano UI 】 lightweight data storage
- 1. 两数之和
猜你喜欢
Super handy drawing tool is recommended
typescript41-class类的私有修饰符
shell script loop statement
UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
typescript45-接口之间的兼容性
Flask的简单介绍及使用方法简介
数据分析 第一篇
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
[Harmony OS] [ArkUI] ets development graphics and animation drawing
深度学习入门之GRU
随机推荐
typescript39-class类的可见修饰符
Modelarts第一次培训
2. 两数相加
Flask Web 报错:
13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence 如何不耍流氓的做运维之-SHELL脚本
Exception (abnormal) and Error (error) difference analysis
ss-4.2 多个eureka集群案例
Redis常用命令
MCM box model modeling method and source analysis of atmospheric O3
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
Redis6学习笔记
【转】最小描述长度准则MDL(Minimun Description Length)
阿凡提的难题
对角矩阵(diagonal matrix)
【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
VR全景展打造专属元宇宙观展空间
用scikit-learn学习谱聚类
Talking about GIS Data (5) - Geographic Coordinate System
typescript43-类型兼容性说明