結果
| 問題 | No.3421 How Many Peaks? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-11 14:24:33 |
| 言語 | Rust (1.92.0 + proconio + num) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 869 bytes |
| 記録 | |
| コンパイル時間 | 24,674 ms |
| コンパイル使用メモリ | 412,096 KB |
| 実行使用メモリ | 16,208 KB |
| 最終ジャッジ日時 | 2026-01-11 14:25:03 |
| 合計ジャッジ時間 | 27,902 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 8 |
ソースコード
use num::pow;
use proconio::input;
const RANGE : i64 = 5000000;
fn main() {
input! {
t: usize,
}
for _ in 0..t {
solve();
}
}
fn solve() {
input! {
a: f64, b: f64, c: f64, d: f64
}
let mut cnt = 0;
// xを全探索
for x in -RANGE..=RANGE {
// 直近3つを調べる
// x1 < x2 > x3または x1 > x2 < x3の個数を数える
let x1 = calc_fx(a, b, c, d, (x-1) as f64 / 10000.0);
let x2 = calc_fx(a, b, c, d, x as f64 / 10000.0);
let x3 = calc_fx(a, b, c, d, (x+1) as f64 / 10000.0);
if x1 < x2 && x2 > x3 { cnt += 1; }
else if x1 > x2 && x2 < x3 { cnt += 1; }
else {}
// println!("x={}: {} {} {}", x, x1, x2, x3);
}
// dbg!(cnt);
println!("{}", if cnt == 2 {"Yes"} else {"No"});
}
fn calc_fx(a: f64, b: f64, c: f64, d: f64, x: f64 ) -> f64 {
a * pow(x, 3) as f64 +
b * pow(x, 2) as f64 +
c * pow(x, 1) as f64 +
d
}