結果

問題 No.278 連続する整数の和(2)
ユーザー koba-e964koba-e964
提出日時 2015-09-11 17:54:09
言語 Rust
(1.77.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 1,834 ms
コンパイル使用メモリ 122,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 22:43:18
合計ジャッジ時間 2,107 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 13 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 13 ms
4,384 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 16 ms
4,380 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 8 ms
4,384 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 AC 7 ms
4,384 KB
testcase_17 AC 13 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
  let mut ret = String::new();
  std::io::stdin().read_line(&mut ret).ok();
  return ret;
}

fn parse<T : std::str::FromStr>(s : &str) -> T {
  match s.parse::<T>() {
    Ok(t) => t,
    _    => panic!(),
  }
}

fn main() {
  let mut n : i64 = parse(getline().trim());
  let mut sum = 0i64;
  if n % 2 == 0 {
    n /= 2;
  }
  let mut x = 1i64;
  while x * x <= n {
    if n % x != 0 {
      x += 1;
      continue;
    }
    sum += x;
    if x * x != n {
      sum += n / x;
    }
    x += 1;
  }
  println!("{}", sum);
}
0