Pagini recente » Cod sursa (job #2252653) | Cod sursa (job #1022244) | Cod sursa (job #906491) | Cod sursa (job #2123177) | Cod sursa (job #2580971)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
const int m=9973;
const int nmax=1000005;
int t;
long long n;
bitset<nmax>viz;
vector<int>divi;
long long lgp(int a,int b){
long long res=1LL,pop=a;
for(int i=0;(1<<i)<=b;i++){
if(b&(1<<i)) res=(res*pop)%m;
pop=(pop*pop)%m;
}
return res;
}
int main(){
// ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
// srand(chrono::steady_clock::now().time_since_epoch().count());
for(int i=2;i<=nmax;i++){
if(viz[i]==0){
divi.push_back(i);
for(int j=2*i;j<=nmax;j+=i) viz[j]=1;
}
}
fin >> t;
while(t--){
fin >> n;
long long nrdiv=1LL,sum=1LL;
for(auto i:divi){
if(n%i==0){
int cnt=0;
while(n%i==0){
cnt++;
n/=i;
}
nrdiv*=(cnt+1LL);
nrdiv=(nrdiv)%m;
if(cnt){ long long x=(lgp(i,cnt+1LL)-1LL);
if(x<0LL) x+=m;
sum=(sum*x)%m;
x=lgp(i-1LL,m-2LL);
sum=(sum*x)%m; } }
}
if(n>=2LL) nrdiv=(nrdiv*2LL)%m;
if(n>=2){
long long x=(lgp(n,2LL)-1LL);
if(x<0LL) x+=m;
sum=(sum*x)%m;
x=lgp(n-1LL,m-2LL);
sum=(sum*x)%m;
}
fout << nrdiv << ' ' << sum << '\n';
}
}