zoukankan      html  css  js  c++  java
  • 亲和数

    亲和数Time Limit: 1 Sec  Memory Limit: 64 MB
    Submit: 294  Solved: 127
    [Submit][Status][Web Board]

    Description

    如果a的因子和等于b,b的因子和等于a,且a≠b,则称a,b为亲密数对。比如220的所有真约数(即不是自身的约数)之和为: 1+2+4+5+10+11+20+22+44+55+110=284。 284的所有真约数和为: 1+2+4+71+142=220。你的任务就编写一个程序,判断给定的两个数是否是亲和数

    Input

    输入数据第一行包含一个数M,接下有M行,每行一个实例,包含两个整数A,B; 其中 0≤A,B≤99999。

    Output

    对于每个测试实例,如果A和B是亲和数的话输出YES,否则输出NO。

    Sample Input

    2
    220 284
    100 200

    Sample Output

    YES
    NO
     
    #include<iostream>
    using namespace std;
    int main()
    {   int i,n,m,s,sn,l,m1;
    cin>>n;
     for(i=0;i<n;i++)
     { sn=0;
     l=0;
     cin>>m>>m1;
     for(s=1;s<m;s++)
    	 if(m%s==0)
    		 sn=sn+s;
       for(s=1;s<m1;s++)
       if(m1%s==0)
    	l=l+s;
    
    
    
    
       if(m==l&&sn==m1)
    	   cout<<"YES"<<endl;
       else
    	    cout<<"NO"<<endl;
    
    
    
    
     }
      return 0;
    
    }

  • 相关阅读:
    Sony Z1 USB 调试
    消除“Unfortunately, System UI has stopped”的方法
    变动数据模拟cons
    string to integer
    single number
    罗马数字转为阿拉伯数字
    整数逆序
    回文数字
    回文字符串
    count and say
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3767044.html
Copyright © 2011-2022 走看看