#include <iostream>
using namespace std;
int main(){
int n;
while(cin >> n){
int count=0;
for(int i=6;i<=n;i++){
int temp=0;
for(int j=1;j<i;j++){//注意j<n,因为求和时不算这个数的自身
if(i%j==0)
temp+=j;
}
if(temp==i)
count++;
}
cout << count << endl;
}
return 0;
} #一样的解法,python的劣势就凸显出来了,复杂度过大;看了其他人的解法......只能说很骚,但没有意义 while True: try: n=int(input()) count=0 for i in range(6,n+1): temp=0 for j in range(1,i): if i%j==0: temp+=j if temp==i: count+=1 print(count) except: break

京公网安备 11010502036488号