QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587499#9381. 502 Bad GatewayylsfmfmWA 143ms3740kbC++14889b2024-09-24 20:19:002024-09-24 20:19:00

Judging History

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

  • [2024-09-24 20:19:00]
  • 评测
  • 测评结果:WA
  • 用时:143ms
  • 内存:3740kb
  • [2024-09-24 20:19:00]
  • 提交

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(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;}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3740kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 143ms
memory: 3552kb

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'