結果

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

ソースコード

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 <= n {
        if n % i == 0 {
            if m % i == 0 {
                ans = max(ans, i);
            }
            if m % (n / i) == 0 {
                ans = max(ans, n / i)
            }
        }
        i += 1;
    }
    println!("{}", ans);
}
0