Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <bitset>
- #define Nmax 1000001
- #define RUP ios::sync_with_stdio(false); f.tie(0); g.tie(0);
- #define TOT f.close(); g.close();
- using namespace std;
- ifstream f("bookface.in");
- ofstream g("bookface.out");
- int P[Nmax/3] , np;
- bool E[Nmax];
- inline long long putere(long long n , long long e);
- int main()
- {
- RUP
- E[1] = E[0] = 1;
- for(int i = 2 ; i * i <= Nmax ; i++)
- if(E[i] == false)
- for(int j = i * i ; j <= Nmax ; j += i)
- E[j] = true;
- for(int i = 2 ; i < Nmax ; i++)
- if(E[i] == false)
- P[++np] = i;
- int n;
- long long x , s = 1;
- f >> n;
- for(int i = 1 ; i <= n ; i++)
- {
- f >> x;
- s = 1;
- int d = 1 , e = 1;
- while(x > 1)
- {
- if(x % P[d] == 0)
- {
- e = 0;
- while(x % P[d] == 0)
- x /= P[d] , e++;
- e *= 2;
- s = s * (putere(P[d] , e + 1) - 1) / (P[d] - 1);
- }
- else
- d++;
- if(P[d] * P[d] > x && x > 1)
- s = s * (putere(x , 3) - 1) / (x - 1) , x = 1;
- }
- g << s << "\n";
- }
- TOT
- }
- inline long long putere(long long n , long long e)
- {
- long long p = 1;
- for(int i = 1 ; i <= e ; i++)
- p *= n;
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement