結果

問題 No.278 連続する整数の和(2)
ユーザー te-shte-sh
提出日時 2017-06-07 18:26:20
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 89,920 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 13:59:01
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 12 ms
4,380 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,384 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 9 ms
4,384 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions

void main()
{
  auto n = readln.chomp.to!long;

  auto y = n % 2 ? n : n / 2;
  auto my = y.to!real.sqrt.to!long + 1;

  auto r = 0L;
  foreach (s; 1..my+1) {
    if (y % s == 0) {
      r += s;
      auto t = y / s;
      if (s != t) {
        r += t;
      }
    }
  }

  writeln(r);
}
0