QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583841#9381. 502 Bad GatewayhuangceWA 166ms3648kbC++17757b2024-09-22 23:04:252024-09-22 23:04:26

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 23:04:26]
  • 评测
  • 测评结果:WA
  • 用时:166ms
  • 内存:3648kb
  • [2024-09-22 23:04:25]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int ll
using namespace std;
constexpr int N=1e6+7;
constexpr int M=2e3+7;
int t;
void solve()
{
	cin>>t;
	int c=sqrt(2*t);
	int c1=0;
	if(c*c!=2*t) c1=c+1;
	int fenzi=c*c-c+2*t;
	int fenmu=2*c;
	int fenzi1=c1*c1-c1+2*t;
	int fenmu1=2*c1;
	int tt=__gcd(fenzi,fenmu);
	fenzi/=tt,fenmu/=tt;
	if(c1!=0)
	{
		int tt1=__gcd(fenzi1,fenmu1);
		fenzi1/=tt1,fenmu1/=tt1;
		if(fenzi*fenmu1>fenmu*fenzi1)
		{
			cout<<fenzi<<' '<<fenmu<<endl;
		}
		else
		{
			cout<<fenzi1<<' '<<fenmu1<<endl;
		}
	}
	else cout<<fenzi<<' '<<fenmu<<endl;
}
signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T=1; cin>>T;
	while(T--){solve();}
	return 0;
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 166ms
memory: 3648kb

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
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
1 1
1 1
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
2000006281 44722
2000006281 44722
20...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000006281 44722'