結果

問題 No.2479 Sum of Squares
ユーザー ldsyb
提出日時 2023-09-22 21:23:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,040 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 3,556 ms
コンパイル使用メモリ 252,996 KB
最終ジャッジ日時 2025-02-17 00:16:54
ジャッジサーバーID
(参考情報)
judge5 / judge2
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

int main()
{
    int64_t s;
    cin >> s;

    vector<int64_t> as;

    int64_t x = 1;
    while ((x + 1) * (x + 1) <= s)
    {
        x++;
    }

    while (0 < s)
    {
        while (x * x <= s)
        {
            as.push_back(x * x);
            s -= x * x;
        }
        x--;
    }

    cout << as.size() << endl;
    for (auto &&a : as)
    {
        cout << a << ' ';
    }
    cout << endl;

    return 0;
}
0