- 【验证性】第7章:函数 完美数
关系运算实验
- 2024-1-22 18:35:09 @
#include <bits/stdc++.h> using namespace std;
bool IfPerfectNum(int x) { int y=1; for(int i=2;ii<=x;i++) { if(x%i==0) { y+=i; if(ii != x) y+=x/i; if(y>x) return false;
}
} if(y!=x) return false; return true; } int main() { cout<<"0\n"; for(int i=6;i<=10000;i++) { if(IfPerfectNum(i)) cout<<i<<endl; }
return 0;
}
0 comments
No comments so far...
Information
- ID
- 275
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 36
- Accepted
- 10
- Uploaded By