Pagini recente » Cod sursa (job #549213) | Cod sursa (job #323263) | Cod sursa (job #1868328) | Cod sursa (job #1451017) | Cod sursa (job #1820689)
#include <fstream>
#include <vector>
#include <bitset>
#define mod 0x26F5
#define MXP 1000010
using namespace std;
vector <int> prim;
ofstream t ("ssnd.out");
class parser{
public:
parser() {}
parser(const char *file_name){
input_file.open(file_name);
cursor=0;
input_file.read(buffer,SIZE);}
inline parser &operator >>(int64_t &n){
while(buffer[cursor]<'0' or buffer[cursor]>'9') inc();
n=0;
while('0'<=buffer[cursor] and buffer[cursor]<='9')
n=n*10+buffer[cursor]-'0',inc();
return *this;}
private:
ifstream input_file;
static const int SIZE=0x8000;
char buffer[SIZE];
int cursor=0;
inline void inc(){
if(++cursor==SIZE)
cursor=0,input_file.read(buffer,SIZE);
}
};
int64_t pow(int64_t x,int64_t y)
{
x%=mod;
int64_t m=1;
while(y){
if(y&1)
m=(m*x)%mod;
x=(x*x)%mod;
y>>=1;
}
return m;
}
void ciuruieste()
{
bitset <MXP> prime;
for (int i=1;((i*i)<<1)+(i<<1)<MXP;++i)
if(!prime[i])
for(int j=((i*i)<<1)+(i<<1);(j<<1)+1<MXP;j+=(i<<1)+1)
prime[j]=true;
prim.push_back(2);
for(int i=1;(i<<1)+1<MXP;++i)
if(!prime[i])
prim.push_back((i<<1)+1);
}
void solve(int64_t target){
int how_many=1,sum=1,aux;
for (auto i:prim){
if (i*i>target) break;
if (target%i==0){aux=0;
while (target%i==0){target/=i;++aux;}
how_many*=(1+aux);
sum=(((sum*((pow(i,aux+1)-1)%mod))%mod)*(pow(i-1,mod-2)%mod))%mod;}
}
if (target>1){
how_many=how_many<<1;
sum=(sum*(target+1))%mod;}
t<<how_many<<" "<<sum<<'\n';
}
int main()
{
parser f ("ssnd.in");
int64_t aux,q;
ciuruieste();
f>>q;
for (;q;--q)
f>>aux,solve(aux);
return 0;
}