QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587866 | #9381. 502 Bad Gateway | ylsfmfm | WA | 0ms | 3736kb | C++14 | 797b | 2024-09-24 22:08:29 | 2024-09-24 22:08:30 |
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 !a ? b:gcd(b%a,a);
}
void slove(int t){
double zc=sqrt(2*t);
int l=zc,r=l+1;
int c= zc-l*1.0 > r*1.0-zc ? r:l;
l= 2*t+c*(c-1) , r= 2*c;
int gcdab=gcd(l,r);
cout<<gcdab<<'\n';
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;}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3736kb
input:
3 1 2 3
output:
2 1 1 2 3 2 4 2 1
result:
wrong answer 1st lines differ - expected: '1 1', found: '2'