結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2016-02-26 14:42:58 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 563 bytes |
コンパイル時間 | 1,248 ms |
コンパイル使用メモリ | 158,948 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 13:57:06 |
合計ジャッジ時間 | 2,145 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 WA * 5 |
ソースコード
#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(N&&N%10==0)N/=10; } while (M % 2 == 0){ M /= 2; N *= 5; while(N&&N%10==0)N/=10; } if (M == 1) cout << N << endl; else cout << -1 << endl; }