Cod sursa(job #798775)

Utilizator icb_mnStf Cic icb_mn Data 17 octombrie 2012 10:35:55
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include<fstream>
#define LL long long
#define M 9973

using namespace std;

LL n;
int t;

int main()
{
    ifstream f("ssnd.in");
    ofstream g("ssnd.out");

    f>>t;

    for(int i = 1; i <= t; ++i)
    {
        f>>n;
        LL nr = 2;
        LL sum = n + 1;
        if(n == 1)sum = nr = 1;
        else
        {
            LL j;
            for(j = 2; j * j < n; ++j)
                if(!(n % j))
                {
                    nr = (nr + 2) % M;
                    sum = (sum + j + n / j) % M;
                }
            if(j * j == n)
            {
                nr = (nr + 1) % M;
                sum =(sum + j) % M;
            }
        }
        g<<nr<<' '<<sum <<'\n';
    }

    g.close();

    return 0;
}