1008红玫瑰数

#include 
/*
作者: 
厦门理工学院
    计算机与信息工程学院 FnLock
时间:201711923:51:48 
程序描述:
3_7红玫瑰数

Time Limit:1000MS  Memory Limit:65536K
Total Submit:1838 Accepted:536

Description

若正整数N的所有因子之和等于N的倍数,则称N为红玫瑰数,如28的因子之和为1+2+4+7+14+28=56=28*2,故28是红玫瑰数,求: 
(1)[1700]之间最大的红玫瑰数。 
(2)[1700]之间有多少个红玫瑰数。 

Input

无

Output

第一行输出一个整数,代表[1,700]之间最大的红玫瑰数。 
第二行输出一个整数,代表[1,700]之间有多少个红玫瑰数。 
第三行从小到大输出[1,700]之间的所有红玫瑰数,每两个数之间用空格隔开。

Sample Input


无
Sample Output


672
6
1,,,,
Source
*/ 
int main()
{

    int commonFactor;
    int x,y;
    int count = 0;
    int add=0; 
    for(x=1;x<=700;x++)
    {
        for(y=1;y<=x;y++)
        {
            if(x%y==0)
            {
                add+=y;

            }
        }
        if(add%x==0)
        {
            count++;
            commonFactor=x;
        }
        add=0;  
    }
    printf("%d\n",commonFactor);
    printf("%d\n",count);
    for(x=1;x<=700;x++)
    {
        for(y=1;y<=x;y++)
        {
            if(x%y==0)
            {
                add+=y;
            }
        }
        if(add%x==0)
        {
            printf("%d ",x);
        }
        add=0;  
    }
    return 0;
 } 

你可能感兴趣的:(ACM)