QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586875#9381. 502 Bad Gatewayyeah14WA 0ms3676kbC++17645b2024-09-24 16:18:492024-09-24 16:18:51

Judging History

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

  • [2024-09-24 16:18:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3676kb
  • [2024-09-24 16:18:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
	ll n;
	cin >> n;
	ll k = sqrt(2 * n);
	ll x1 = k * k - k + 2 * n;
	ll x2 = (k + 1) * (k + 1) - (k+1)+2 * n;
	ll y1 = 2 * k;
	ll y2 = 2 * (k + 1);
	double ans1 = double(x1) / double(y1), ans2 = double(x2) / double(y2);
	if (ans1 > ans2) {
		int k = __gcd(x1, y1);
		x1 /= k;
		y1 /= k;
		cout << x1 << " " << y1 << endl;
	}
	else {
		int k = __gcd(x2, y2);
		x2 /= k;
		y2 /= k;
		cout << x2 << " " << y2 << endl;
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

1 1
5 3
2 1

result:

wrong answer 2nd lines differ - expected: '3 2', found: '5 3'