QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580423#9381. 502 Bad GatewayxinlengweishangWA 0ms3932kbC++20497b2024-09-21 21:49:462024-09-21 21:49:46

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-21 21:49:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3932kb
  • [2024-09-21 21:49:46]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
    	ll n;
    	cin>>n;
		ll x=(ll)(sqrt(2*n+0.25)-1/2);
		while(((x+1)*(x+2))/2<=n) x++;
//		printf("%lld ",x);
		n-=((x)*(x+1))/2;
//		printf("%lld\n",n);
		ll fenzi=x*(x+1)+n;
		ll fenmu=x+1;
		printf("%lld %lld\n",fenzi/gcd(fenzi,fenmu),fenmu/gcd(fenzi,fenmu));
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

1 1
5 3
2 1

result:

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