親和數:
#include<iostream> using namespace std; long long Test(long long n){ long long i,sum=0; for(i=1;i<n;++i){ if(n%i==0) sum+=i; } return sum; } int main(){ long long n; cin>>n; while(n--){ long long a,b; cin>>a>>b; if(Test(a)==b){ if(Test(b)==a) cout<<"YES"<<endl; else cout<<"NO"<<endl; } else cout<<"NO"<<endl; } return 0; }
本文出自 “菜鳥的進階之路” 博客,請務必保留此出處http://beyond316.blog.51cto.com/7367775/1281671