题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
#include <iostream> using namespace std; int main() { int a, b=0,c,i; while (cin >> a ) { // 注意 while 处理多个 case for ( i=1; i<a; i++) { for (int j=1; j*j<=i; j++) { if (i%j==0) { b=b+j; } } if (i==b) { c++; } } } cout << c << endl; }