結果

問題 No.3331 Consecutive Cubic Sum
コンテスト
ユーザー a01sa01to
提出日時 2025-11-03 01:01:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 3,101 ms
コンパイル使用メモリ 278,556 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-03 01:01:59
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

inline ll cube(ll x) { return x * x * x; }

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<pair<ll, ll>> ans;
  ll r = 1, sum = 0;
  for (ll l = 1; l <= 1'000'000; ++l) {
    while (sum + cube(r) <= n) sum += cube(r++);
    if (sum == n) ans.push_back({ l, r - 1 });
    sum -= cube(l);
  }
  cout << ans.size() << '\n';
  for (auto [l, r] : ans) cout << l << ' ' << r << '\n';
  return 0;
}
0