結果
| 問題 | 
                            No.2479 Sum of Squares
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-01-29 07:08:06 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,026 ms / 2,000 ms | 
| コード長 | 2,295 bytes | 
| コンパイル時間 | 2,599 ms | 
| コンパイル使用メモリ | 247,812 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-28 09:59:54 | 
| 合計ジャッジ時間 | 9,974 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#ifndef INCLUDED_main
#define INCLUDED_main
#include __FILE__
const ll mod = 998244353; using mint = atcoder::modint998244353;
//const ll mod = 1000000007; using mint = atcoder::modint1000000007;
// @brief 繰り返し二乗法を利用した、x^nの求値
ll power(ll x, ll n){
  ll res = 1;
  while(n){
    if(n & 1) res *= x; // nの2進数表記の下からi(0-indexed)桁目が1なら、x^(2^i)を掛けていく
    x *= x;
    n >>= 1; // (n = n>>1 nの各ビットを右へシフト)
  }
  
  return res;
}
int main(){
  ll s; cin >> s;
  ll M = 1;
  while(s >= (M+1)*(M+1)) M++;
  vector<ll> ans;
  while(s >= 1){
    while(s < M*M){
      M--;
    }
    s -= M*M;
    ans.push_back(M*M);
  }
  cout << ans.size() << endl;
  fore(x, ans) cout << x << ' ';
}
#else 
#include <bits/stdc++.h>
#include <atcoder/modint>
using ll = long long;
using ld = long double;
using Graph = std::vector<std::vector<int>>;
#define endl '\n'
#define INF 1000000039
#define LLINF 393939393939393939
#define fore(i, a) for(auto &i : a)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define erep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define part(x, a, b) x.begin()+a, x.begin()+b+1
#define rpart(x, a, b) x.rbegin()+a, x.rbegin()+b+1
#define pcnt(x) __builtin_popcount(x)
#define llpcnt(x) __builtin_popcountll(x)
template<typename T>
using pq = std::priority_queue<T>;
template<typename T>
using pqg = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
bool chmax(T &a, const T &b){
  if(a < b){ a = b; return 1; }
  else return 0;
}
template<typename T>
bool chmin(T &a, const T &b){
  if(a > b){ a = b; return 1; }
  else return 0;
}
// 多次元配列の生成
template<size_t Dimention, typename T>
class Mvector : public std::vector<Mvector<Dimention-1, T>>{
public:
  template<typename N, typename... Sizes>
  Mvector(T init, N n, Sizes... sizes) : std::vector<Mvector<Dimention-1, T> >(n, Mvector<Dimention-1, T>(init, sizes...))
  { }
};
template<typename T>
class Mvector<1, T> : public std::vector<T>{
public:
  template<typename N>
  Mvector(T init, N n) : std::vector<T>(n, init)
  { }
};
using namespace std;
#endif