Problem Description

1+2+4+5+10+11+20+22+44+55+110＝284。

Input

Output

Sample Input
2
220 284
100 200

Sample Output
YES
NO

3个回答

``````#include<iostream>

using namespace std;

#include<stdio.h>

int sum(int b)

{

int s=0,k;

for(k=1;k<=b/2;k++)

{

if(b%k==0) s=s+k;

}

return s;

}

int main()

{

int n;

int x,y;

while(scanf("%d", &n)!=EOF)

{

while(n--)

{

scanf("%d%d",&x,&y);

if(x==sum(y)&&y==sum(x))

cout<<"YES"<<endl;

else

cout<<"NO"<<endl;

}

}

return 0;

}
``````

int main(){
int ....//定义声明变量
scanf()//输入测试组数n
while(n>0){
scanf()//输入每组测试数据num1,num2
sum1=fun2(num1);//调用函数2分别求num1 num2的真约数和
sum2=fun2(num2);
if(sum1==num2&&sum2==num1){
printf("YES\n");
}else{
printf("NO\n");
}
n--;
}
return 0;
}
// fun2
int fun2(int num){
.....//求真约数合的代码逻辑写在这里就可以了
return sum;
}

``````#include<stdio.h>

int check(int b){
int s=0,k;
for(k=1;k<=b/2;k++){
if(b%k==0)
s+=k;
}
return s;
}

int main() {
int n;
int x,y;
printf("Sample Input\n");
scanf("%d", &n);
int nums[2*n];
for(int i=0;i<2*n;i+=2){
scanf("%d %d",&x,&y);
nums[i]=x;
nums[i+1]=y;
}
printf("Sample Output\n");
for(int i=0;i<2*n;i+=2){
if(nums[i]==check(nums[i+1]) && nums[i+1]==check(nums[i])){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}
``````