代码球跳qwq
查看原帖
代码球跳qwq
663199
Tachibana27楼主2024/1/4 19:47

过样例,0pts

#include<bits/stdc++.h>
#define int long long
#define qwert std::cout<<"\n"
#define asdf std::cout<<" "
inline int read(){
	int s=0;
	int w=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')
			w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())
		s=s*10+ch-'0';
	return s*w;
}

void write(int x) {
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9)
		write(x/10);
	putchar(x%10+'0');
	return;
}
int n;
bool check(int x){
	int sum=0;
	for(int i=2;pow(i,3)<=x;i++)
		sum+=x/pow(i,3);
	return sum<n;
}
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	int l=1;
	int r=LONG_LONG_MAX;
	int ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}
		else
			r=mid-1;
	}
	ans++;
	if(check(ans))
		ans=-1;
	write(ans);
	return 0;
}

2024/1/4 19:47
加载中...