結果

問題 No.3331 Consecutive Cubic Sum
コンテスト
ユーザー Vi24E
提出日時 2025-10-01 02:28:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 555 bytes
コンパイル時間 1,760 ms
コンパイル使用メモリ 198,224 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-02 21:10:41
合計ジャッジ時間 8,468 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 TLE * 1 -- * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll cube_sum(ll x){
    return x * (x + 1) / 2 * x * (x + 1) / 2;
}

int main() {
    ll n;
    cin >> n;
    assert(1 <= n && n <= 1000000000000000000);

    ll l = 1, r = 1;
    vector<pair<ll, ll>> ans;
    while (l * l * l <= n){
        ll t = cube_sum(r) - cube_sum(l - 1);
        if (t == n){
            ans.push_back({l, r});
        }
        if (t <= n) r++;
        else l++;
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) cout << x << " " << y << endl;
}
0