QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#588397#9381. 502 Bad GatewayJTaoWA 0ms3508kbC++201.1kb2024-09-25 10:28:012024-09-25 10:28:03

Judging History

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

  • [2024-09-25 10:28:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3508kb
  • [2024-09-25 10:28:01]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e7 + 5;
const int mod = 1e9 + 7;

int gcd(int a, int b) {
    int c;
    while (b) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
void prin(int a, int b, int c, int d) {
    int t1 = a * d + b * c;
    int t2 = b * d;
    int t = gcd(t1, t2);
    cout << t1 / t << " " << t2 / t << '\n';
}
void solve() {
    int n;
    cin >> n;
    int t = sqrt(2 * n);
    if (t * t == n) {
    }
    else {
        int t1, t2;
        if (t * t > n) {
            t1 = t - 1; 
            t2 = t;
        }
        else {
            t1 = t;
            t2 = t + 1;
        }
        int tt1 = (t1 - 1) * t1 + 2 * n;
        int tt2 = (t2 - 1) * t2 + 2 * n;
        if (tt1 * t2 > tt2 * t1) {
            prin(t2 - 1, 2, n, t2);
        }
        else {
            prin(t1 - 1, 2, n, t1);
        }
    }

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
    cin >> T;
    while (T--)
        solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3508kb

input:

3
1
2
3

output:

3 2
2 1

result:

wrong answer 1st lines differ - expected: '1 1', found: '3 2'