結果

問題 No.278 連続する整数の和(2)
ユーザー xuzijian629xuzijian629
提出日時 2018-11-02 23:36:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 201,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-30 18:14:29
合計ジャッジ時間 2,572 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 11 ms
6,948 KB
testcase_10 AC 14 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,940 KB
testcase_13 WA -
testcase_14 AC 8 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 11 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    i64 n;
    i64 ret = 0;
    cin >> n;

    __int128_t s = __int128_t(n) * (n + 1) / 2;
    i64 g = __gcd(s, __int128_t(n));

    for (i64 i = 1; i * i <= g; i++) {
        if (n % i == 0) {
            ret += i;
            if (i != n / i) {
                ret += n / i;
            }
        }
    }
    cout << ret << endl;
}
0