結果

問題 No.3331 Consecutive Cubic Sum
コンテスト
ユーザー himueu
提出日時 2026-10-29 00:38:39
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 52 ms / 5,000 ms
+ 938µs
コード長 696 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,181 ms
コンパイル使用メモリ 181,684 KB
実行使用メモリ 19,064 KB
最終ジャッジ日時 2026-10-29 00:38:48
合計ジャッジ時間 8,840 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

int main() {
    using namespace std;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    using u128 = __uint128_t;
    constexpr u128 M = 1000100;
    vector<u128> acc(M, 0);
    for (u128 i = 1; i < M; i++) { acc[i] = acc[i - 1] + i * i * i; }

    long long n;
    cin >> n;
    vector<pair<int, int>> ans;
    for (int l = 0; l < static_cast<int>(M); l++) {
        int r = lower_bound(acc.begin(), acc.end(), acc[l] + n) - acc.begin();
        if (acc[l] + n == acc[r]) { ans.emplace_back(l + 1, r); }
    }

    cout << ans.size() << "\n";
    for (auto [l, r] : ans) { cout << l << " " << r << "\n"; }
}
0