結果
問題 |
No.604 誕生日のお小遣い
|
ユーザー |
|
提出日時 | 2017-12-06 17:35:36 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 14,373 ms |
コンパイル使用メモリ | 378,740 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 19:19:42 |
合計ジャッジ時間 | 12,386 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
macro_rules! input { ($($x:ident : $t:ty), *) => { $(let $x: $t;)* { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); $($x = it.next().unwrap().parse().unwrap();)* assert!(it.next().is_none()); } }; } fn check(a: i64, b: i64) -> bool { if b == 0 { return false } return a * b / b != a } fn main() { input!(a: i64, b: i64, c: i64); let mut ok: i64 = c; let mut ng: i64 = 0; while ok - ng > 1 { let mid = (ok + ng) / 2; if check(b - 1, mid / a) { ok = mid; } else if (b-1)*(mid/a) >= c-mid { ok = mid; } else { ng = mid; } } println!("{}", ok); }