結果

問題 No.276 連続する整数の和(1)
ユーザー tonyu0
提出日時 2020-04-29 15:49:25
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 568 bytes
コンパイル時間 13,941 ms
コンパイル使用メモリ 402,156 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-11-28 19:51:07
合計ジャッジ時間 22,885 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::max;
use std::io::*;

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: u64 = itr.next().unwrap().parse().unwrap();
    let m = n * (n + 1) / 2;

    let mut ans = 0;
    let mut i = 1;
    while i * i <= m {
        if m % i == 0 {
            if i <= n {
                ans = max(ans, i);
            }
            if m / i <= n {
                ans = max(ans, m / i)
            }
        }
        i += 1;
    }
    println!("{}", ans);
}
0