結果
問題 |
No.25 有限小数
|
ユーザー |
![]() |
提出日時 | 2016-05-06 18:51:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 533 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 56,668 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-05 10:11:09 |
合計ジャッジ時間 | 1,161 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 1 |
ソースコード
#include <algorithm> #include <iostream> using namespace std; long long N, M; int main() { cin >> N >> M; long long gcd = __gcd(N, M); N /= gcd; M /= gcd; int cnt2 = 0, cnt5 = 0; while (M % 2 == 0) { cnt2++; M /= 2; } while (M % 5 == 0) { cnt5++; M /= 5; } while (N % 10 == 0) { N /= 10; } if (M > 1) { cout << -1 << endl; } else { for (int i = 0; i < cnt5 - cnt2; i++) { N *= 2; N %= 10; } for (int i = 0; i < cnt2 - cnt5; i++) { N *= 5; N %= 10; } cout << N << endl; } return 0; }