[yukicoder] No. 1224 I hate Sqrt Inequality
問題
方針
\( \dfrac{a}{b} \) が有限小数であるとき、\( 10^na \bmod b = 0 \) を満たす 非負整数\( n \) が存在します。したがって、非負整数 \( x, y \) と自然数 \( c \) を用いて、
\[ b = 2^x5^yc \ (c \bmod 2 \neq 0 \wedge c \bmod 5 \neq 0)\]
としたとき、\( a \bmod c = 0 \) ならば有限小数となり、そうでなければ。無限小数となります。
コード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a, b; cin >> a >> b; if (a % b == 0) { cout << "No\n"; return 0; } while (b % 2 == 0) { b /= 2; } while (b % 5 == 0) { b /= 5; } if (a % b == 0) { cout << "No\n"; } else { cout << "Yes\n"; } return 0; }
ディスカッション
コメント一覧
まだ、コメントがありません