QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742119#9622. 有限小数ucup-team4074#Compile Error//C++141.2kb2024-11-13 15:55:162024-11-13 15:55:23

Judging History

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

  • [2024-11-13 15:55:23]
  • 评测
  • [2024-11-13 15:55:16]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

void solve();

const int N = 1e5 + 10, P = 998244353;
int pw_2[N], pw_5[N];

signed main() {
    fast
    pw_2[0] = pw_5[0] = 1;
    for (int i = 1; i <= 30; i++)pw_2[i] = pw_2[i - 1] * 2, pw_5[i] = pw_5[i - 1] * 5;
    int t = 1;
    cin >> t;
    while (t--) solve();
}

void solve() {
    int a, b, ansc(1e9), ansd(0);
    cin >> a >> b;
    ansc = b - a;
    ansd = b;
    int nb(b);
    while (nb % 2 == 0)nb /= 2;
    while (nb % 5 == 0)nb /= 5;
    if (nb == 1) {
        cout << 0 << " " << 1 << '\n';
        return;
    }
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 12; j++) {
            if (pw_2[i] * pw_5[j] * b <= 1000000000) {
                int c(nb - (pw_2[i] * pw_5[j] * a) % nb);
                if (ansc > c / (gcd(c, pw_2[i] * pw_5[j] * b))) {
                    ansc = c / (gcd(c, pw_2[i] * pw_5[j] * b));
                    ansd = pw_2[i] * pw_5[j] * b / (gcd(c, pw_2[i] * pw_5[j] * b));
                }
            }
        }
    }
    cout << ansc << " " << ansd << '\n';
    return;
}
/*
4
1 2
2 3
3 7
19 79
 */

詳細信息

answer.code: In function ‘void solve()’:
answer.code:37:33: error: ‘gcd’ was not declared in this scope
   37 |                 if (ansc > c / (gcd(c, pw_2[i] * pw_5[j] * b))) {
      |                                 ^~~