結果

問題 No.648  お や す み 
ユーザー tonyu0
提出日時 2020-04-05 01:25:46
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 11,386 ms
コンパイル使用メモリ 380,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-03 07:53:42
合計ジャッジ時間 13,108 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 80 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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 n: f64 = itr.next().unwrap().parse().unwrap();
    // 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 {
        println!("YES");
        println!("{}", ans.trunc());
    } else {
        println!("NO");
    }
}
0