QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582898#9381. 502 Bad GatewayjokerTWA 332ms3616kbC++141.2kb2024-09-22 17:44:282024-09-22 17:44:32

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 17:44:32]
  • 评测
  • 测评结果:WA
  • 用时:332ms
  • 内存:3616kb
  • [2024-09-22 17:44:28]
  • 提交

answer

/*
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sqrt(a) sqrtl(a)
#define abs(a) llabs(a)
#define pow(a) powl(a)
typedef  pair<int,int> pi ;
#define if1(x) for(int i =1 ;i<=x;i++)
#define if0(x) for(int i = 0;i<x;i++)
#define jf0(x) for(int j = 0;j<x;j++)
#define jf1(x) for(int j = 1;j<=x;j++)
#define pb push_back
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int N = 2e5+10;
    int m,n;
pi gg(int x){
    int p =x;
    int sum = p*(p+1)/2;
    int fm = p;
    int fz = sum+n-p;
    int gc = __gcd(fz,fm);
    fm /= gc;
    fz /= gc;
    return {fz,fm};
}
void solve(){
    cin>>n;
    if(n == 1){
        cout<<1<<" "<<1<<endl;return;
    }
    int x = sqrt(2*x);
    vector<pi> ns;
    pi ans = {inf,1};
    for(int i = -10;i<=10;i++){
        if( i+x <=0)continue;
        if(i+x>n)break;
        pi te = gg(i+x);
        if(ans.first * te.second >te.first *ans.second) ans = te;
    }
    
    cout<<ans.first<<" "<<ans.second<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr); 
    int t=1;
    cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
/*


*/

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 332ms
memory: 3612kb

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
200000009 2
1 1
1 1
200000009 2
1 1
200000009 2
1 1
1 1
1 1
200000009 2
1 1
1 1
200000009 2
1 1
200000009 2
200000009 2
1 1
200000009 2
1 1
1 1
200000009 2
1 1
200000009 2
200000009 2
1 1
200000009 2
200000009 2
200000009 2
200000009 2
200000009 2
200000009 2
1 1
1 1
200000009 2
1 1
200000009 2
...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '200000009 2'