結果
| 問題 |
No.734 Careful Engineer
|
| コンテスト | |
| ユーザー |
特命ログイン
|
| 提出日時 | 2018-09-28 22:58:42 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 940 bytes |
| コンパイル時間 | 13,880 ms |
| コンパイル使用メモリ | 379,592 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 07:08:46 |
| 合計ジャッジ時間 | 14,177 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 WA * 2 |
ソースコード
use std::io::{stdin, Read};
fn main() {
let mut buf = String::new();
stdin().read_to_string(&mut buf).unwrap();
let mut tok = buf.split_whitespace();
let mut get = || tok.next().unwrap();
macro_rules! get {
($t:ty) => (get().parse::<$t>().unwrap());
() => (get!(u64));
}
let a = get!() * 60;
let b = get!();
let c = get!() * 60 * 60;
// a*x < b*x + c (better manual)
// x < c/(a-b)
// x < ceil(c/(a-b))
// a*x >= b*x + c (better auto)
// (a-b)*x >= c
// x >= c/(a-b)
// x > floor(c/(a-b))
let mut lp = 0;
let mut rp = 1_000_000_001;
while lp < rp {
let x = (lp + rp) / 2;
let ax = a * x;
let bxc = b * x + c;
if ax < bxc {
lp = x + 1;
} else {
rp = x;
}
}
if rp < 1_000_000_001 {
println!("{}", rp);
} else {
println!("-1");
}
}
特命ログイン