QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#585396#9381. 502 Bad GatewaylittTangWA 315ms3708kbC++23952b2024-09-23 20:38:122024-09-23 20:38:12

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 20:38:12]
  • 评测
  • 测评结果:WA
  • 用时:315ms
  • 内存:3708kb
  • [2024-09-23 20:38:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lson (p << 1)
#define rson (p << 1 | 1)
#define lowbit(x) x & -x
#define PII pair<int, int>
#define B 30

const int maxn = 1e2 + 10;
const int maxm = 2e5 + 10;
const int mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const int lINF = 0x3f3f3f3f3f3f3f3f;

void solve(){
	int t;
	cin >> t;
	int c1 = floor(sqrt(2.0 * t));
	int c2 = ceill(sqrt(2.0 * t));
	if((1.0 * (c1 * c1 - c1 + 2 * t) / (2.0 * c1)) < (1.0 * (c2 * c2 - c2 + 2 * t) / (2.0 * c2))){
		int x = c1 * c2 - c1 + 2 * t;
		int y = 2 * c1;
		int d = __gcd(x, y);
		cout << x / d << " " << y / d << endl;
	}
	else{
		int x = c2 * c2 - c2 + 2 * t;
		int y = 2 * c2;
		int d = __gcd(x, y);
		cout << x / d << " " << y / d << endl;
	}
}

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

	return 0;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 315ms
memory: 3708kb

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
3999967841 89442
1 1
1 1
3999967841 89442
1 1
3999967841 89442
1 1
1 1
1 1
3999967841 89442
1 1
1 1
3999967841 89442
1 1
3999967841 89442
3999967841 89442
1 1
3999967841 89442
1 1
1 1
3999967841 89442
1 1
3999967841 89442
3999967841 89442
1 1
3999967841 89442
3999967841 89442
3999967841 89442
39...

result:

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