QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580888 | #9381. 502 Bad Gateway | buhuisuanfa | WA | 347ms | 3676kb | C++20 | 958b | 2024-09-22 00:40:33 | 2024-09-22 00:40:34 |
Judging History
answer
#include<bits/stdc++.h>
#define sz(x) (x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
using namespace std;
using ll = long long;
struct frac {
int a, b;
bool operator<(const frac &rhs) {
return 1ll * a * rhs.b < 1ll * b * rhs.a;
}
};
void solve() {
int T;
cin >> T;
int sqrtT = sqrt(2 * T);
int lo = max(sqrtT - 10, 1);
int hi = min(sqrtT + 10, T);
auto calc = [&](int i) {
frac res;
res.b = 2 * i;
res.a = 1ll * i * i - i + 2 * T;
int d = gcd(res.a, res.b);
res.a /= d;
res.b /= d;
return res;
};
frac ans = calc(1);
for (int i = lo; i <= hi; i++) {
frac temp = calc(i);
if(ans < temp) ;
else ans = temp;
}
cout << ans.a << " " << ans.b << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int t;
std::cin >> t;
for (; t; t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 347ms
memory: 3676kb
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 -147969243 44711 1 1 1 1 -147969243 44711 1 1 -147969243 44711 1 1 1 1 1 1 -147969243 44711 1 1 1 1 -147969243 44711 1 1 -147969243 44711 -147969243 44711 1 1 -147969243 44711 1 1 1 1 -147969243 44711 1 1 -147969243 44711 -147969243 44711 1 1 -147969243 44711 -147969243 44711 -147969243 44711 -1...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '-147969243 44711'