結果
問題 | No.25 有限小数 |
ユーザー |
|
提出日時 | 2024-02-06 21:34:37 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 1,866 ms |
コンパイル使用メモリ | 175,924 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-28 12:14:31 |
合計ジャッジ時間 | 2,812 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
module main; import std; void main() { auto N = readln.chomp.to!ulong; auto M = readln.chomp.to!ulong; auto G = gcd(N, M); N /= G; M /= G; if (M == 1uL) { while (N % 10 == 0) N /= 10; writeln(N % 10); return; } while (M % 10 == 0) M /= 10; auto L = M; while (L % 2 == 0) L >>= 1; while (L % 5 == 0) L /= 5; if (L != 1uL) { writeln(-1); return; } BigInt A = N, B = M, Q, R; do { divMod(A, B, Q, R); A = R * 10; } while (R != 0); writeln(Q.toDecimalString().stripRight("0")[$-1]); }