結果

問題 No.1224 I hate Sqrt Inequality
ユーザー uk714uk714
提出日時 2020-09-12 01:50:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 171,220 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-09 07:59:11
合計ジャッジ時間 2,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 45 ms
4,376 KB
testcase_11 AC 105 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://yukicoder.me/problems/no/1224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// 素因数分解
map<int, int> factorize(int n) {
    map<int, int> V;

    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            V[i]++;
            n /= i;
        }
    }
    if (n > 1)
        V[n]++;
    return V;
}

void solve() {
    // ① これ以上、既約分数になるまで約分(これ以上、約分できない状態にする)
    // ② 分母を素因数分解して「2と5」以外の素数を持つ場合、無限小数
    // ③ 上記以外は、有限小数
    int A, B;
    cin >> A >> B;
    int t = gcd(A, B);
    A /= t;
    B /= t;
    auto fa = factorize(B);
    bool mugen = false;
    for (auto &x : fa) {
        if (x.first != 2 && x.first != 5) {
            mugen = true;
        }
    }
    if (mugen) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}
0