QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751098#9622. 有限小数OrangeSummerWA 0ms3664kbC++231.4kb2024-11-15 17:05:312024-11-15 17:05:31

Judging History

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

  • [2024-11-15 17:05:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-11-15 17:05:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl '\n'
#define all(_x) _x.begin(), _x.end()
#define range(_x, _st, _ed) (_x.begin() + _st), (_x.begin() + _ed)
#define rep(_x, _y, _z) for (int _x = _y; _x <= _z; _x++)
#define matrix(_x, _y, _z) vector<vector<int>>(_x, vector<int>(_y, _z))
#define debug(_x) cout << #_x << '=' << _x << endl
using i64 = long long;
using i128 = __int128;
using pii = pair<int, int>;
using mat = vector<vector<int>>;
using u64 = unsigned long long;
constexpr int N = 2e5 + 10;
// dont use umap!!!

i64 exgcd(i64 a, i64 b, i64 &x, i64 &y) {
    if (!b) {
        x = 1, y = 0;
        return a;
    }
    i64 g = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
}

void solve()
{
    i64 a, b;
    cin >> a >> b;
    auto w = b;
    while(w % 2 == 0) w /= 2;
    while(w % 5 == 0) w /= 5;
    i64 x, y, c = 1e9, d = -1;
    exgcd(w, b / w, x, y);
    for(int i = 1; 1ll *i * w <= 1e9; i *= 2)
        for(int j = 1; 1ll * i * j * w <= 1e9; j *= 5)
        {
            i64 temp_c = w - (y * a * i * j % w + w) % w;
            i64 temp_d = w * i * j;
            if(temp_c < c) c = temp_c, d = temp_d;
        }
    cout << c << ' ' << d << '\n';
}

signed main()
{
    IOS;
    int _ = 1;
    cin >> _;

    while (_--) solve();

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

4
1 2
2 3
3 7
19 79

output:

1 1
1 3
1 4375
3 316

result:

wrong answer Jury found better answer than participant's 0 < 1 (Testcase 1)