HDOJ_1215_七夕节

AC代码:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

long int hanshu(long int a)
{
    long int sum=1;
    long int bi=(int)sqrt((double)a);
    for(long int i=2;i<=bi;i++)
    {
        if(a%i==0)
        {
            sum+=i;
            if(i!=a/i)
                sum+=a/i;
        }
    }
    
    return sum;
}

int main(void)
{
    freopen("in.txt","r",stdin);
    long long n;
    scanf("%lld",&n);
    while(n--)
    {
        long int a,sum;
        scanf("%ld",&a);
        sum=hanshu(a);
        printf("%lld\n",sum);
    }

    fclose(stdin);
    return 0;
}

 

posted @ 2018-11-30 20:53  pha创噬  阅读(106)  评论(0编辑  收藏  举报