QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589007#9381. 502 Bad GatewayjjjjjxsWA 240ms3660kbC++14975b2024-09-25 15:39:032024-09-25 15:39:03

Judging History

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

  • [2024-09-25 15:39:03]
  • 评测
  • 测评结果:WA
  • 用时:240ms
  • 内存:3660kb
  • [2024-09-25 15:39:03]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
#define INF 0x3f3f3f3f
#define fr first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 1e6 + 10;

ll A(ll c,ll t)
{
	return c*(c-1)+2*t;
}

ll B(ll c,ll t)
{
	return 2*c;
}

void solve()
{
	int t;
	cin>>t;
	
	//三分解对勾函数
	ll lmid , rmid;
	ll lo = 0 , hi = t + 1;//[1,t]
	while(lo + 3 < hi)
	{
		ll lmid = lo + (hi - lo) / 3;
		ll rmid = hi - (hi - lo) / 3;
		if(A(lmid,t) * B(rmid,t) < A(rmid,t) * B(lmid,t)) hi = rmid;
		else lo = lmid;
	}

	//cout << hi - 1 << endl;

	//ll ansc = (A(hi-1,t)*B(hi,t)<A(hi,t)*B(hi-1,t)) ? hi-1  : hi ;
	ll above = A(hi-1,t);
	ll below = B(hi-1,t);
	ll g = __gcd(above,below);
	above /= g;
	below /= g;
	cout << above <<' '<< below << endl;
}


signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T=1; cin>>T;
	while(T--) solve();
	return 0;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 240ms
memory: 3604kb

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
37301136089154041 273134162
1 1
1 1
37301136089154041 273134162
1 1
37301136089154041 273134162
1 1
1 1
1 1
37301136089154041 273134162
1 1
1 1
37301136089154041 273134162
1 1
37301136089154041 273134162
37301136089154041 273134162
1 1
37301136089154041 273134162
1 1
1 1
37301136089154041 273134...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '37301136089154041 273134162'