QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#594092 | #9307. Clock Master | zqx# | WA | 3ms | 8800kb | C++23 | 1.1kb | 2024-09-27 19:04:30 | 2024-09-27 19:04:32 |
Judging History
answer
#include<bits/stdc++.h>
#define AC return 0;
#define int long long
#define pii pair<int,int>
#define all(tar) tar.begin(),tar.end()
const int N = 3e5 + 10;
const int mod=998244353;
using namespace std;
int pre[N];
double val[N];
void Init()
{
for (int i = 2; i < N; i++)
pre[i] = pre[i - 1] + i;
for (int i = 2; i < N; i++)
val[i] = val[i - 1] + log(i);
}
void Solve()
{
int n;
cin >> n;
if (n == 1)
{
cout << "0\n";
return ;
}
int l, r;
l = 1, r = n;
int tot = -1;
while (l <= r)
{
int mid = (l + r) >> 1;
if (pre[mid] <= n)
{
tot = mid;
l = mid + 1;
}
else
r = mid - 1;
}
int rm = n - pre[tot];
double res = val[tot - rm] + val[tot + 1] - val[tot - rm + 1];
cout << setprecision(10) << res << "\n";
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);cout.setf(ios::fixed);
int T;cin>>T;
Init();
while(T--){
Solve();
}
AC
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 8800kb
input:
3 2 7 10
output:
0.6931471806 2.4849066498 3.4011973817
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 8604kb
input:
5000 580 4555 4654 1420 53 1076 1226 2733 2285 348 2104 2293 3447 4208 710 307 1763 1142 3027 2151 3182 1546 3398 867 2380 830 4211 3117 3058 2251 1890 3961 4003 3991 4167 4976 1765 3235 2644 4070 4644 3645 875 3005 4769 4934 3846 2941 255 946 4164 1372 1193 3056 4472 508 3949 2473 4490 88 4014 2953...
output:
85.9417702126 339.4287645097 345.3794070623 158.0285431236 15.1044125731 131.5662806745 144.6065659409 243.8593420295 217.8620972569 60.5685545804 205.6537072984 218.0051981005 283.2555471357 322.9511811992 99.5670012329 55.1703918789 182.7420693922 137.1774160868 260.9513578850 209.4547040507 269.6...
result:
wrong answer 1st numbers differ - expected: '59.8085219', found: '85.9417702', error = '0.4369486'