QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580831#9381. 502 Bad GatewayobliviatecquptWA 161ms3636kbC++20684b2024-09-22 00:15:002024-09-22 00:15:01

Judging History

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

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

answer

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


void solve(){
	int t;
	cin >> t;
	int g = sqrt(2*t);
	int a = 1e9, b = 1;
	for(int w = max(1ll, g - 10); w <= min(t, g + 10); w++){
		int ta = w*w - w + 2*t;
		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: 3548kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 161ms
memory: 3636kb

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
2000408815 44731
1 1
1 1
2000408815 44731
1 1
2000408815 44731
1 1
1 1
1 1
2000408815 44731
1 1
1 1
2000408815 44731
1 1
2000408815 44731
2000408815 44731
1 1
2000408815 44731
1 1
1 1
2000408815 44731
1 1
2000408815 44731
2000408815 44731
1 1
2000408815 44731
2000408815 44731
2000408815 44731
20...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000408815 44731'