注意开Long Long ,避免爆int;
枚举n的值,判断满足条件的解的个数;
r为右边界,n的最大值<=81e16,l为右边界;
mid/h为y满足当前x=i时的条件个数,即为当前条件下解的个数
#include<bits/stdc++.h> using namespace std; #define ll long long ll m,n,x,y; ll check(ll mid) { ll ans=0; for(ll i=2;(i*i*i)<=mid;i++) { ll h=i*i*i; if(h<0) break; if(mid/h) ans+=mid/h; } return ans; } int main() { while(scanf("%lld",&m)!=EOF) { ll r=1e17,l=1,res=0; while(l<=r) { ll mid=(l+r)/2; if(check(mid)>=m) res=mid,r=mid-1; else l=mid+1; } if(check(res)==m) cout<<res<<endl; else cout<<-1<<endl; } }