Pagini recente » Cod sursa (job #370841) | Cod sursa (job #2290569) | Cod sursa (job #1384773) | Cod sursa (job #1089145) | Cod sursa (job #1014278)
/***************************************************
* Alex Palcuie
* Romania - 2013
* alex [dot] palcuie [at] gmail [dot] com
* http://palcu.blogspot.com/
****************************************************/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>
#include <climits>
#include <fstream>
#include <sstream>
using namespace std;
// Defines
#define NAME(n) #n
#define prv(v,n) dbv((v), (#v), (n))
#define prw(v) dbw((v), (#v))
#define F first
#define S second
#define pb push_back
#define sz size()
#define mp make_pair
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
// Helpers
template <typename T> inline void dbv(const T * v, const char * name, int n){
fprintf(stderr, "=== %s ===\n", name);
for(int i=0; i<n; i++)
cerr << v[i] << " ";
cerr << '\n';
}
template<typename T> void dbw(const std::vector<T>& t, const char * name){
fprintf(stderr, "=== %s ===\n", name);
unsigned n = t.size();
for(typename std::vector<T>::size_type i=0; i<n; ++i)
std::cerr << t[i] << ' ';
cerr << '\n';
}
// Structs
// Constants
const int MAX_PRIM = 1000000;
const int INF = 0x3f3f3f3f;
const int MOD = 9973;
// Globals
int n;
bitset<MAX_PRIM> isPrim;
vector<int> primes;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
// Functions
void generatePrimes(){
for(int k=2; k<MAX_PRIM; k++)
if(!isPrim[k]){
primes.pb(k);
for(int j=k; j<MAX_PRIM; j+=k)
isPrim[j] = 1;
}
}
inline bool canDivideWith(ull x, int d){
return (x % d == 0);
}
void solveFor(ull x){
ull nDiv = 1, sDiv = 1, i = 0;
ull sqrtOfX = sqrt(x);
while(primes[i] <= sqrtOfX && x != 1){
if(canDivideWith(x, primes[i])){
ull d = 0, sumTerm = primes[i];
while(canDivideWith(x, primes[i])){
d++;
x /= primes[i];
sumTerm *= primes[i];
}
nDiv *= (d + 1);
ull term = (sumTerm - 1) / (primes[i] - 1);
sDiv = (sDiv * term) % MOD;
}
i++;
}
if(x != 1){
nDiv *= 2;
ull term = (x * x - 1) / (x - 1);
sDiv = (sDiv * term) % MOD;
}
fout << nDiv << ' ' << sDiv << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
generatePrimes();
fin >> n;
for(int i=0; i<n; i++){
ull x;
fin >> x;
solveFor(x);
}
return 0;
}