Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ll long long
- #include <bits/stdc++.h>
- using namespace std;
- const int OO = 1e9;
- const double EPS = 1e-9;
- map<ll,ll> factors(ll cn) {
- map<ll,ll> f;
- for(ll i = 2; i * i <= cn; (i == 2 ? i++: i+=2)) {
- while(cn%i == 0) {
- f[i]++;
- cn /= i;
- }
- }
- if(cn > 1) {
- f[cn]++;
- }
- return f;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- ll n;
- while(true) {
- cin >> n;
- if(!n)
- break;
- vector<ll> divisors;
- for(ll i = 1; i * i <= n; i++) {
- if(n%i == 0) {
- divisors.push_back(i);
- if(n/i != i) {
- divisors.push_back(n/i);
- }
- }
- }
- map<ll,ll> f = factors(n);
- /*cout << "factors are: ";
- for(pair<ll,ll> fp : f) {
- cout << "{" << fp.first << "," << fp.second << "} ";
- }
- cout << "\ndivisors are: ";
- for(int div : divisors) {
- cout << div << " ";
- }
- cout << "\n";*/
- ll ans = 0;
- for(ll div : divisors) {
- map<ll,ll> df = factors(div);
- ll possible = 1;
- for(pair<ll,ll> fp : f) {
- if(fp.second > df[fp.first]) {
- possible *= 2;
- }
- }
- ans += possible;
- }
- cout << n << " " << (ans+1)/2 << "\n";
- }
- /*int cnt = 0;
- for(int i = 1; i <= 100; i++) {
- for(int j = 1; j <= 100; j++) {
- int g = __gcd(i,j);
- if((i*j)/g == 12) {
- cout << "{" << i << "," << j << "}\n";
- cnt++;
- }
- }
- }
- cout << "cnt = " << cnt << "\n";*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement