QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#587504 | #9381. 502 Bad Gateway | ylsfmfm | WA | 151ms | 3672kb | C++14 | 912b | 2024-09-24 20:21:55 | 2024-09-24 20:21:55 |
Judging History
answer
// 操作二期望操作时间: 1+(1-c/n)+(1-c/n)^2+........ = n/c
// 操作一期望操作时间: 1/c * (1+2+3.....+c)
// 选定区间 1~c 则期望操作时间: n/c + (c+1)/2 -1 (从第0秒开始)
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=1e1+3,inf=0x3f3f3f3f,mod=998244353;
int t,n;
int gcd(int a,int b){
return !b ? a:gcd(b,a%b);
}
void slove(int n){
double zc=(1+ sqrt(1+8*n) )/2;
// cout<<fixed<< setprecision(8)<<zc<<'\n';
int l=zc,r=l+1;
int c;
if(l>n) c=n;
else if(r>n) c=l;
else c= zc-l*1.0 > r*1.0-zc ? r:l;
// cout<<c<<'\n';
l= 2*n+c*(c-1) , r= 2*c;
int gcdab=gcd(l,r);
cout<< l/gcdab<<' '<< r/gcdab<<'\n';
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>t;
while(t--){
cin>>n;
slove(n);
}
return 0;}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 151ms
memory: 3620kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 1 1 1 1 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 2000006281 44722 2000006281 44722 20...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000006281 44722'