QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#579892#9381. 502 Bad GatewayxuemanWA 532ms3756kbC++17694b2024-09-21 19:01:542024-09-21 19:01:55

Judging History

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

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

answer

#include<bits/stdc++.h>
#define int __int128_t
#define endl '\n'
using namespace std;

void print(int x)
{
	if (x == 0)
		return;
		print(x/10);
	cout << (long long)(x % 10);
	

}

int gcd(int a,int b)
{
	while (b ^= a ^= b ^= a %= b)
		;
	return a;

}


signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n;
	cin>>n;
	while(n--)
	{
		long long T;
		cin>>T;
		int k=(T-1)/2+1;
		int c1=T-1-k,c2=T,a=k+1;
		int x=(k+1)*(k+2)/2;
		int ans1,ans2;
		ans1=x*(c2-c1)+a*c1;
		ans2=(c2-c1)*(c2-c1);
		int m = gcd(ans1,ans2);
		ans1/=m;
		ans2/=m;
		print(ans1);
		cout << ' ';
		print(ans2);
		cout << '\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 532ms
memory: 3756kb

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
125000001250000000 500000001
1 1
1 1
125000001250000000 500000001
1 1
125000001250000000 500000001
1 1
1 1
1 1
125000001250000000 500000001
1 1
1 1
125000001250000000 500000001
1 1
125000001250000000 500000001
125000001250000000 500000001
1 1
125000001250000000 500000001
1 1
1 1
1250000012500000...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '125000001250000000 500000001'