社区讨论
30pt WA一个点求调:(
P8574 「DTOI-2」星之影参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m3dpmytu
- 此快照首次捕获于
- 2024/11/12 08:24 去年
- 此快照最后确认于
- 2025/11/04 14:53 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char buf_ans[114];
ll next_n(double last_ans=0,ll get_n=0){
//last_ans<n<=1e18
sprintf(buf_ans,"%.6f",last_ans);
for(ll i=0,x=0;;i++){
if(buf_ans[i]=='.')return get_n^x;
if(i&1)x*=10;
else x=x*10+(buf_ans[i]^48);
}
}
double lans;
int T;
ll n;
ll f[6000005];
ll calc(double x){
ll re=floor(sqrt(sqrt(x))+0.5);
return re;
}
const int N=31623;
double pre[6000060];
void Init(){
auto x=[](ll i){
long long l=0,r=1e18,ans=0;
while(l<=r){
ll mid=(l+r)>>1;
if(calc(mid)>i)r=mid-1;
else ans=mid,l=mid+1;
}
return ans;
};
for(int i=1;i<=N;++i){
f[i]=x(i);
pre[i]=pre[i-1]+1.0*(f[i]-f[i-1])*(1/(1.0*i));
}
}
int main(){
scanf("%d",&T);
Init();
while(T--){
scanf("%lld",&n); n=next_n(lans,n);
int p=lower_bound(f+1,f+1+N,n)-f;
if(f[p]==n)lans=pre[p];
else lans=pre[p-1]+(n-f[p-1])*(1.0/(1.0*p));
printf("%.6lf\n",lans);
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...