这个复杂度为什么TLE?
查看原帖
这个复杂度为什么TLE?
1208546
AnotherDream楼主2024/4/25 20:52
#include<bits/stdc++.h>
#define int long long
using namespace std;
int zh(int x)
{
    map<int,int> mp;
    for(int i=2;i*i<=x;i++)
    {
        while(x%i==0)
        {
            mp[i]++;
            x/=i;
        }
    }
    if(x!=1)
    {
        mp[x]++;
    }
    int ns=INT_MIN;
    for(auto e:mp)
    {
        ns=max(ns,e.first);
    }
    return ns;
}
signed main()
{
    int n,b;
    cin>>n>>b;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
    	if(zh(i)<=b)
    	{
    		ans++;
		}
	}
	cout<<ans;
    return 0;
}
2024/4/25 20:52
加载中...