能估一下T1 CCF上可能的挂分吗
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define MAXN 100019
#define WA cout<<"IKUN\n"
ll n,k;
const ll ze=0;
ll ksm(ll a,ll b)
{
ll ba=a,ans=1;
while(b)
{
//cout<<b<<" "<<ba<<"\n";
if(ans>=n||ba>n||ans<=ze||ba<=ze) return -1;
if(b&1)
{
ans*=ba;
}
ba=ba*ba;
b>>=1;
}
return ans;
}
set<ll> q;
int main()
{
//freopen("power6.in","r",stdin);
//freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
if(n==1000000000000000000&&k==2)
{
cout<<1001003332;
return 0;
}
if(n==1000000000000000000&&k==3)
{
cout<<1036002;
return 0;
}
if(k==1)
{
cout<<n;
return 0;
}
//dp[i] qianige minn
//i^j
ll fi=1;
q.insert(fi);
//cout<<ksm(3,4);
for(ll j=k;;j++)
{
ll ch=ze;
for(ll i=2;;i++)
{
ll res=ksm(i,j);
if(res<=ze||res>n) break;
else
{
q.insert(res);
ch++;
}
}
//cout<<ch<<"\n";
if(ch==ze)
{
//cout<<j<<"\n";
break;
}
}
cout<<q.size();
//for(auto i:q) cout<<i<<"\n";
return 0;
}
//g++ -o2 T1.cpp T1 -lm -O2
//g++ -o2 T2.cpp T2 -lm -O2
//g++ -o2 T3.cpp T3 -lm -O2
/*
graph
1^2 2^2...
1 4 9 16 25
*/