1 solutions

  • 0
    @ 2025-3-10 18:51:05

    思路

    对于N我们可以表示为,N = p1k1p_1^{k_1} p2k2p_2^{k_2} ... (唯一分解定律

    例:12 = 222^2 * 313^1

    此时题目的g(x) = (k1+1k_1 + 1 ) * (k2+1k_2 + 1 ) * .... (约数个数定理

    例:g(12) = 6

    然后我们由反素数定义可以推出k1k_1 k2k_2 必须是严格不上升

    例:18 = 212^1 * 323^2 但是18不是反素数

    ok,思考到这里我们就可以对这些质数的指数进行暴力枚举即可。同时这里注意一下数据范围2e9只需要考虑2,3,5,7,11,13,17,19,23这九个数即可

    ac code:

    #include<bits/stdc++.h>
    typedef long long LL;
    using namespace std;
    const int N = 1e5 + 10;
    int n,prime[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23,};
    pair<int, int> ans;
    void dfs(int p,int now,int cnt,int maxn){
    	if(p > 9 || now > n)return;
    	if(cnt > ans.second || (cnt == ans.second && now < ans.first))ans = {now,cnt};
    	for(int i = 1;i <= maxn;++ i)
    	{
    		if(1ll * now * prime[p] > n)return;
    		now *= prime[p];
    		dfs(p + 1,now,cnt * (i + 1),i); 
    	}
    }
    
    int main ()
    {
    	cin >> n;
    	ans = {1,1};
    	dfs(1,1,1,1000);
    	cout << ans.first << "\n";
    
    
    
    	return 0;
    }
    
    
    • 1

    Information

    ID
    7015
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    47
    Accepted
    6
    Uploaded By