QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581247 | #9381. 502 Bad Gateway | Doubeecat | WA | 415ms | 4916kb | C++14 | 1.8kb | 2024-09-22 11:06:46 | 2024-09-22 11:06:48 |
Judging History
answer
/*
Undo the destiny.
*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define ll long long
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pii pair<ll,ll>
#define mp make_pair
char buf[1 << 20], *p1, *p2;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)?EOF: *p1++)
template <typename T> inline void read(T &t) {
int v = getchar();T f = 1;t = 0;
while (!isdigit(v)) {if (v == '-')f = -1;v = getchar();}
while (isdigit(v)) {t = t * 10 + v - 48;v = getchar();}
t *= f;
}
template <typename T,typename... Args> inline void read(T &t,Args&... args) {
read(t);read(args...);
}
const ll mod = 998244353;
const double eps = 1e-10;
ll gcd(ll a,ll b) {return !b ? a : gcd(b,a%b);}
pii del(pii a,pii b) {
pii c;
c.second = a.second * b.second;
c.first = a.first * b.second - b.first * a.second;
ll g = gcd(c.first,c.second);
c.first /= g,c.second /= g;
return c;
}
pii add(pii a,pii b) {
pii c;
c.second = a.second * b.second;
c.first = a.first * b.second + b.first * a.second;
ll g = gcd(c.first,c.second);
c.first /= g,c.second /= g;
return c;
}
void solve() {
int t;read(t);
int c1 = ceil((double)sqrt(2*t)),c2 = floor((double)(sqrt(2*t)));
//cerr << c1 << " " << c2 << endl;
pii now1 = del(add(mp(c1,2),mp(t,c1)),mp(1,2));
pii now2 = del(add(mp(c2,2),mp(t,c2)),mp(1,2));
if (del(now1,now2).first < 0) printf("%lld %lld\n",now1.first,now1.second);
else printf("%lld %lld\n",now2.first,now2.second);
}
signed main() {
int T;read(T);
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 231ms
memory: 4916kb
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 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1999961560 44721 19...
result:
ok 1000000 lines
Test #3:
score: -100
Wrong Answer
time: 415ms
memory: 4856kb
input:
1000000 158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125...
output:
316511467 17791 1755824328 41903 1204845831 34711 49954223 7068 1723292600 41513 623676492 17659 867835058 29459 952344999 30860 262700539 11461 422085442 20545 1942776701 44077 251551941 7093 1463896912 38261 1645584679 40566 901913913 30032 107573492 3667 1965228547 44331 323457022 17985 176178307...
result:
wrong answer 7th lines differ - expected: '867864517 29460', found: '867835058 29459'