QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580824#9381. 502 Bad GatewayobliviatecquptWA 153ms3644kbC++20682b2024-09-22 00:12:522024-09-22 00:12:53

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 00:12:53]
  • 评测
  • 测评结果:WA
  • 用时:153ms
  • 内存:3644kb
  • [2024-09-22 00:12:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define ll long long


void solve(){
	int n;
	cin >> n;
	int g = sqrt(n);
	int a = 1e9, b = 1;
	for(int w = max(1ll, g - 10); w <= min(n, g + 10); w++){
		int ta = w*w - w + 2*n;
		int tb = 2*w;
		if(a*tb > tb*b) a = ta, b = tb;
	}
	
	int c = __gcd(a, b);
	cout << a / c << ' ' << b / c << '\n';
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _;
    cin >> _;
    while(_--){
        solve();
        // if(solve()) printf("YES\n");
        // else printf("NO\n");
    }
    
    // solve();
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 153ms
memory: 3644kb

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
187534487 3954
1 1
1 1
187534487 3954
1 1
187534487 3954
1 1
1 1
1 1
187534487 3954
1 1
1 1
187534487 3954
1 1
187534487 3954
187534487 3954
1 1
187534487 3954
1 1
1 1
187534487 3954
1 1
187534487 3954
187534487 3954
1 1
187534487 3954
187534487 3954
187534487 3954
187534487 3954
187534487 3954
...

result:

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