QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770552#9622. 有限小数k1nsom#Compile Error//C++20940b2024-11-21 22:19:432024-11-21 22:19:46

Judging History

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

  • [2024-11-21 22:19:46]
  • 评测
  • [2024-11-21 22:19:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define int long long

void solve()
{
    int a, b;
    cin >> a >> b;
    const int up = 1e18;
    pair<int, int> ans = {up, up};
    for (int i = 1; b * i <= up; i *= 2)
    {
        for (int j = 1; b * i * j <= up; j *= 5)
        {
            int d = b * i * j;
            if (d > up)
                break;
            int v = a * i * j;
            int k = (v + b - 1) / b;
            int aa = k * b - v, bb = d, gd = __gcd(aa, bb);
            aa /= gd, bb /= gd;
            if (bb <= 1e9)
                ans = min(ans, {aa, bb});
        }
    }
    if (c == 1e9)
    {
        exit(-1);
    }
    auto [c, d] = ans;
    cout << c << ' ' << d << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:28:9: error: ‘c’ was not declared in this scope
   28 |     if (c == 1e9)
      |         ^