Cod sursa(job #3161985)

Utilizator fortyforBroscoi Mihai fortyfor Data 28 octombrie 2023 11:11:54
Problema Suma si numarul divizorilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
#include <iostream>
#include <fstream>
std::ifstream fin ("ssnd.in");
std::ofstream fout ("ssnd.out");

int main()
{
    unsigned short t;
    fin >> t;

    for (int i=0;i<t;i++)
    {
        unsigned long long n;
        fin >> n;
        unsigned short s=0;
        bool C[n]{};
        for (unsigned long long i=2;i<n;i++)
        {
            if (C[i]==false) {
                for (unsigned long long j=2*i;j<=n;j+=i)
                {
                    C[j]=true;
                }
            }
        }
        int c=0;
        for (unsigned long long j=1;j*j<=t;t++)
        {
            if (C[j]==false && t%j==0 ){
                c+=1+(j*j!=t);
                s=(s+j+(j*j!=t)*t/j)%9973;
            }
        }
        fout << c << " " << s << "\n";
    }
    return 0;
}