結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2020-04-05 01:37:49 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 14,262 ms |
コンパイル使用メモリ | 393,220 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 07:54:16 |
合計ジャッジ時間 | 13,609 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 79 WA * 5 |
ソースコード
use std::io::*; const EPS: f64 = 1e-10; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let m: u64 = itr.next().unwrap().parse().unwrap(); let n = m as f64; // x ^ 2 + x - n * 2 == 0 // x = (sqrt(8 * n + 1) - 1) / 2 let ans = ((n * 8.0 + 1.0).sqrt() - 1.0) / 2.0; if ans.fract() < EPS { if (ans.trunc() * (ans.trunc() + 1.0) / 2.0) as u64 == m { println!("YES"); println!("{}", ans.trunc()); } else { println!("NO"); } } else { println!("NO"); } }