Pagini recente » Cod sursa (job #3265118) | Cod sursa (job #2390389) | Cod sursa (job #730220) | Cod sursa (job #747182) | Cod sursa (job #2831195)
#include <fstream>
#include <bitset>
#include <vector>
#define LL long long
std::ifstream fin ("ssnd.in");
std::ofstream fout ("ssnd.out");
const int LIM = 1e6;
std::bitset <LIM+5> frq;
std::vector <int> p;
LL gauss(LL k){
return k * (k + 1) / 2;
}
int sumdiv(LL number){
LL result = 0;
for(int i=1; i<=number/i; i++){
result += i * (number / i - i + 1), result %= 9973;
result += 1LL * gauss(number/i) - 1LL * gauss(i), result %= 9973;
}
return result;
}
signed main (){
frq[0] = frq[1] = true;
for(int i=4; i<=LIM; i+=2)
frq[i] = true;
for(int i=3; i<=LIM/i; i+=2)
for(int j=i*i; j<=LIM; j+=i)
frq[j] = true;
p.push_back(2);
for(int i=3; i<=LIM; i+=2)
if(frq[i] != true)
p.push_back(i);
LL q, x, sol;
fin>>q;
while(q--){
fin>>x, sol = sumdiv(x) - sumdiv(x-1);
int div=1;
for(int i=0; i < (int)p.size() && p[i] <= x / p[i]; i++){
int pow = 0;
while(x % p[i] == 0){
pow++;
x /= p[i];
}
div *= (pow+1);
}
if(x != 1)
div *= 2;
fout<<div<<' '<<sol<<'\n';
}
return 0;
}