結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2022-12-19 21:37:24 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,012 bytes |
コンパイル時間 | 1,525 ms |
コンパイル使用メモリ | 143,460 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 01:25:42 |
合計ジャッジ時間 | 2,025 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 2 |
ソースコード
#include <iostream>#include <vector>#include <cmath>#include <map>#include <set>#include <iomanip>#include <queue>#include <algorithm>#include <numeric>#include <deque>#include <complex>using namespace std;int main(){long long N, M, X, cnt2=0, cnt5=0, s;cin >> N >> M;if (N % M == 0){X = N/M;while(X != 0){if (X % 10 != 0){cout << X % 10 << endl;return 0;}X /= 10;}}while(M % 2 == 0){cnt2++;M /= 2;}while(M % 5 == 0){cnt5++;M /= 5;}if (M != 1){cout << -1 << endl;return 0;}while(N % 2 == 0 && cnt2 > 0){cnt2--;N /= 2;}while(N % 5 == 0 && cnt5 > 0){cnt5--;N /= 5;}if (cnt2 > 0) s = 5;else s = N % 10;while(cnt5 > 0){s = ((s * 10) / 5) % 10;cnt5--;}cout << s << endl;return 0;}