Submultiple of nowcoder907B n

The meaning of problems

t interrogation times, each time you give a number n, seeking in [1, n] of the number of count about the most about a few number
\ (t \ le 500, n \ le 10 ^ {19} \)

Thinking

First, it is conceivable to prime factorization of n. That \ (n = \ prod \ limits_ {i = 1} ^ n {a_i} ^ {p ^ i} \)

The answer is \ (\ prod \ limits_ {i = 1} ^ n {p_i + 1} \)

Then we find ways to make n minimum, maximum answer.

It can be found, if there \ (a_i <a_j \ & \ & P_i <p_j \) , then the exchange \ (p_i, p_j \) will be better.

In other words, for any \ (a_i <a_j \) has \ (p_i \ ge p_j \)

Then you can search

Code

/*
* @Author: wxyww
* @Date:   2019-05-31 19:26:20
* @Last Modified time: 2019-05-31 21:29:54
*/
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
typedef long long ll;
const int N = 100100;
#define int ll
ll read() {
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
ll dis[N],vis[N],js;
void eur() {
    int n = N - 100;
    for(int i = 2;i <= n;++i) {
        if(!vis[i]) dis[++js] = i;
        for(int j = 1;j <= js && 1ll * dis[j] * i <= n;++j) {
            vis[dis[j] * i] = 1;
            if(i % dis[j] == 0) break;
        }
    }
    return;
}
ll ans;
void solve(ll nans,ll now,ll x,ll lst) {
    for(int i = 1;i <= lst && x >= dis[now];++i)
        solve(nans * (i + 1),now + 1,x /= dis[now],i);
    ans = max(ans,nans);
}

signed main() {
    int T = read();
    eur();
    while(T--) {
        ll x = read();
        ans = 0;
        solve(1,1,x,10000);
        printf("%lld\n",ans);
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/wxyww/p/nowcoder907B.html