QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587504#9381. 502 Bad GatewayylsfmfmWA 151ms3672kbC++14912b2024-09-24 20:21:552024-09-24 20:21:55

Judging History

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

  • [2024-09-24 20:21:55]
  • 评测
  • 测评结果:WA
  • 用时:151ms
  • 内存:3672kb
  • [2024-09-24 20:21:55]
  • 提交

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'