Double Seventh Festival

Double Seventh Festival
               有时候失去的总比得到的多!

Description

The Double Seventh Festival, on the 7th day of the 7th lunar month, is a traditional festival full of romance. On that day, the God of the Love came to the digital kingdom, and annunciated to the people:

Notification

Do you want to know who is your fere? You can find him or her by this means:
Please add all the factors of your ID-Card-Number, and you can find this is your fere's
ID-Card-Number.


The factors of a numer N is the numbers,they being small than the number N ,and can being divided exactly by the number N.
For example, the number 12 has the factors, such as 1,2,3,4,6.

 

Input

The fist line is the number T (1 <= T <= 500000), indicated the number of the test cases.
The next T lines, each line has one integer N( 1 <= N <= 500000), meaning the ID-Card-Number.

Output

For each test case, you should output the fere's ID-Card-Number on a line.

Sample Input

3
2
10
20

 

Sample Output

1
8
22
      这个题目在我刚开始接触ACM的时候做出来最有成就的一个!求各因子之和!
代码如下:

   
  
  
  
#include < cstdio >
int  main()
{
    
int i,j,n,m,sum;
    scanf(
"%d",&n);
    
for(i=0;i<n;i++)
    
{
        sum
=0;
        scanf(
"%d",&m);
        
for(j=1;j*j<=m;j++)
        
{
            
if(m%j==0)
            
{
                sum
=sum+j+m/j;
            }

            
if(j*j==m)
                sum
-=j;
        }

        printf(
"%d\n",sum-m);
    }

    
return 0;
}

你可能感兴趣的:(Double Seventh Festival)