Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4429 Accepted Submission(s): 2771
2 220 284 100 200
YES NO
#include<stdio.h>
void main()
{
int num,a,b,sum_a,sum_b,i;
while(scanf(" %d",&num) != EOF)
for(;num-- && scanf(" %d %d",&a,&b) != EOF;)
{
for(sum_a=0,i=1;i<a;i++)
if(a%i==0)
sum_a+=i;
for(sum_b=0,i=1;i<b;i++)
if(b%i==0)
sum_b+=i;
printf("%s\n",(sum_a==b && sum_b==a)?"YES":"NO");
}
}
#include<stdio.h> int main() { long i,j,M,m,n,s[1000],sum1,sum2; scanf("%d",&M); while(M--) { scanf("%d%d",&m,&n); j=0;sum1=sum2=0; for(i=1;i<=m/2;i++) { if(m%i==0) s[j++]=i; } for(i=0;i<j;i++) sum1+=s[i]; j=0; for(i=1;i<=n/2;i++) { if(n%i==0) s[j++]=i; } for(i=0;i<j;i++) sum2+=s[i]; if(sum1==n&&sum2==m) printf("YES\n"); else printf("NO\n"); } return 0; }