結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2016-10-20 16:04:51 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-11-22 16:35:03 |
合計ジャッジ時間 | 1,196 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
N = raw_input() M = raw_input() if int(N)%int(M) == 0: print filter(lambda c:c!='0', str(int(N)/int(M)))[-1] exit() L = int(M) while L > 1: if L % 2 == 0: L /= 2 elif L % 5 == 0: L /= 5 else: print -1 exit() A = 0 i = 0 M = int(M) while True: if i < len(N): A = A*10 + int(N[i]) else: A *= 10 C, A = A/M, A%M if C != 0: B = C if (A == 0) and i >= len(N)-1: print B break i += 1