QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581242#9381. 502 Bad GatewayDoubeecatWA 199ms4820kbC++141.7kb2024-09-22 11:05:102024-09-22 11:05:10

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 11:05:10]
  • 评测
  • 测评结果:WA
  • 用时:199ms
  • 内存:4820kb
  • [2024-09-22 11:05:10]
  • 提交

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(sqrt(2*t)),c2 = floor(ceil(sqrt(2*t)));
    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;
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 199ms
memory: 4820kb

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'