結果

問題 No.278 連続する整数の和(2)
コンテスト
ユーザー izuru_matsuura
提出日時 2016-11-08 17:31:53
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 636 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,230 ms
コンパイル使用メモリ 121,560 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-05 08:22:05
合計ジャッジ時間 2,182 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/checkedint.d(814): Warning: cannot inline function `core.checkedint.mulu!().mulu`
ulong mulu()(ulong x, uint y, ref bool overflow)
      ^

ソースコード

diff #
raw source code

import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

long f(long n) {
    long ans = 0;
    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans += i;
            if (i * i != n) {
                ans += n / i;
            }
        }
    }
    return ans;
}

void main() {
    long N; readf("%s\n", &N);
    writeln(f(N % 2 == 1 ? N : N / 2));
}
0