結果

問題 No.3331 Consecutive Cubic Sum
コンテスト
ユーザー Mostafa Aboelmagd
提出日時 2025-11-12 01:04:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 6,178 ms
コンパイル使用メモリ 199,724 KB
実行使用メモリ 11,064 KB
最終ジャッジ日時 2025-11-12 01:12:11
合計ジャッジ時間 4,899 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 22 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define el "\n"
#define input(v) for (auto& it : v) cin >> it;
#define int long long
using namespace std;

int intpow(int a, int b) {
    int ans = 1;
    while(b){
        if(b & 1) ans *= a;
        a *= a;
        b /= 2;
    }
    return ans;
}

void solve() {
    int n;
    cin >> n;

    vector<long long> CS(1000001);
    for(int i = 1; i <= 1000000; i++) CS[i] = CS[i-1] + intpow(i,3);

    vector<pair<int,int>> ans;
    for(int i = 0; i <= 100000; i++) {
        auto it = lower_bound(CS.begin(), CS.end(), CS[i] + n);
        if(it != CS.end() && *it - CS[i] == n) {
            int id = it - CS.begin();
            ans.push_back({i+1,id});
        }
    }

    cout << ans.size() << el;
    for(auto &p : ans) cout << p.first << " " << p.second << el;
}

int32_t main() {
    int Tc = 1;
    // cin >> Tc; 
    while(Tc--) solve();
    return 0;
}
0