結果
問題 |
No.604 誕生日のお小遣い
|
ユーザー |
![]() |
提出日時 | 2017-12-09 02:48:13 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 154,776 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 22:56:36 |
合計ジャッジ時間 | 2,236 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 21 |
ソースコード
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.math; import std.range; import std.bigint; void main() { auto l = readln.chomp.split.map!(to!long).array; long a = l[0], b = l[1], c = l[2]; long lb = 1L, rb = 1e18.to!long, mid; while (rb - lb > 1) { mid = (lb + rb) / 2; BigInt money = BigInt(b) * BigInt(mid / a) + BigInt((mid - mid / a)); writeln(money); if (money > BigInt(c)) { rb = mid; } else if (money < BigInt(c)) { lb = mid; } else { rb = mid; break; } } if (BigInt(b) * BigInt(lb / a) + BigInt((lb - lb / a)) >= BigInt(c)) rb = lb; rb.writeln; }