QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#886 | #586653 | #9381. 502 Bad Gateway | ucup-team1769 | ucup-team1769 | Success! | 2024-09-24 14:55:24 | 2024-09-24 14:55:24 |
Details
Extra Test:
Wrong Answer
time: 0ms
memory: 3548kb
input:
1 4
output:
5 2
result:
wrong answer 1st lines differ - expected: '7 3', found: '5 2'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586653 | #9381. 502 Bad Gateway | ucup-team1769 | WA | 463ms | 11212kb | C++20 | 1.5kb | 2024-09-24 14:52:28 | 2024-09-24 14:57:56 |
answer
#include <bits/stdc++.h>
#define int long long
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using namespace std;
void solve() {
int n;
std::cin >> n;
std::vector<int> t(n);
for (int i = 0; i < n; i++) {
std::cin >> t[i];
int ansx = t[i] + 1, ansy = 2;
int g = std::gcd(ansx, ansy);
ansx /= g, ansy /= g;
int f=max((int)(sqrt(t[i]/2)),3ll);
/*
for(int j= 0;j<20;j++)
{
int now=no+j;
if(now<2||now>t[i])
break;
int _=t[i]/now;
int nx=(t[i]-_)*2+(_+1)*(_);
int ny=_*2;
int ng = std::gcd(nx, ny);
nx/=ng,ny/=ng;
if(ansx * ny > nx * ansy)
{
ansx=nx;
ansy=ny;
f=now;
}
}
*/
for(int j=t[i]/(f+1);j<t[i]/(f-1);j++)
{
int nx=(t[i]-j)*2+(j+1)*(j);
int ny=j*2;
int ng = std::gcd(nx, ny);
nx/=ng,ny/=ng;
if(ansx * ny > nx * ansy)
{
ansx=nx;
ansy=ny;
}
}
std::cout << ansx <<" "<< ansy << "\n";
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
//std::cin >> t;
t = 1;
while (t--) {
solve();
}
}