結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2015-04-15 22:09:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 436 bytes |
コンパイル時間 | 1,156 ms |
コンパイル使用メモリ | 159,060 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 14:36:31 |
合計ジャッジ時間 | 2,015 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 2 |
ソースコード
#include "bits/stdc++.h" using namespace std; long long gcd(long long a, long long b){ if (b == 0) return a; return gcd(b, a%b); } int main() { long long N, M; cin >> N >> M; long long g = gcd(N, M); N /= g; M /= g; while (N % 10 == 0) N /= 10; N %= 10; while (M % 5 == 0){ M /= 5; N *= 2; N %= 10; } while (M % 2 == 0){ M /= 2; N *= 5; N %= 10; } if (M == 1) cout << N << endl; else cout << -1 << endl; }