QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587866#9381. 502 Bad GatewayylsfmfmWA 0ms3736kbC++14797b2024-09-24 22:08:292024-09-24 22:08:30

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 22:08:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-09-24 22:08:29]
  • 提交

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'