結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2015-11-06 23:23:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 583 bytes |
コンパイル時間 | 802 ms |
コンパイル使用メモリ | 63,896 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 21:14:39 |
合計ジャッジ時間 | 1,694 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 1 |
ソースコード
#include <iostream> #include <algorithm> #include <numeric> #include <sstream> #include <set> #include <vector> using namespace std; typedef long long LL; LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } int main(int argc, char *argv[]) { LL N, M; cin >> N >> M; LL g = gcd(N, M); LL a = N / g, b = M / g; for (LL d = 2; d <= 5; d += 3) { while ((b % d) == 0) { b /= d; if ((a % d) == 0) { a /= d; } else { a = ((a % 10) * 10) / d; } } } while ((a % 10) == 0) { a /= 10; } LL ans = b == 1 ? (a % 10) : -1; cout << ans << endl; return 0; }