結果

問題 No.278 連続する整数の和(2)
ユーザー rsk0315
提出日時 2019-01-11 03:44:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 23,040 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 07:56:29
合計ジャッジ時間 947 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%jd", &N);
      |     ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdint>

int main() {
    intmax_t N;
    scanf("%jd", &N);
    intmax_t M = ((N%2>0)? N:N/2);
    intmax_t res = 0;
    for (intmax_t i = 1; i*i <= M; ++i) {
        if (M % i == 0) {
            res += i;
            if (i != M / i) res += M / i;
        }
    }
    printf("%jd\n", res);
}
0