此题本公子算了两种方法,还是AT必通

魈凯KBS  •  5个月前


include<bits/stdc++.h>

using namespace std; int wsnd(int n){

int i,s = 0; for(i = 1;i <= n / 2;i++){

if(n % i == 0){
	s = s + i;
}

} return s; } int main(){

int i; for(i = 1;i <= 1000;i++){

if(wsnd(i) == i){
	cout<<i<<endl;
}

} }


评论:

第二种简单又容易通,wq拿定AT

include

using namespace std; int main()

{ int n,i=2; cin>>n; while(i!=n/2)

{

if(n%i==0)

{

n=-1;

break;

}

i++;

} cout<<(n<0?"No":"Yes");

return 0;

}

--------天下无双--------


魈凯KBS  •  5个月前