結果

問題 No.2479 Sum of Squares
ユーザー ldsybldsyb
提出日時 2023-09-22 21:23:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 583 bytes
コンパイル時間 4,231 ms
コンパイル使用メモリ 261,388 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 21:23:59
合計ジャッジ時間 19,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 TLE -
testcase_04 AC 756 ms
4,376 KB
testcase_05 AC 415 ms
4,380 KB
testcase_06 AC 529 ms
4,380 KB
testcase_07 AC 478 ms
4,380 KB
testcase_08 AC 623 ms
4,376 KB
testcase_09 AC 538 ms
4,376 KB
testcase_10 AC 591 ms
4,376 KB
testcase_11 AC 537 ms
4,380 KB
testcase_12 AC 601 ms
4,380 KB
testcase_13 AC 390 ms
4,380 KB
testcase_14 AC 506 ms
4,380 KB
testcase_15 AC 504 ms
4,380 KB
testcase_16 AC 552 ms
4,380 KB
testcase_17 AC 533 ms
4,380 KB
testcase_18 AC 510 ms
4,376 KB
testcase_19 AC 567 ms
4,376 KB
testcase_20 AC 560 ms
4,376 KB
testcase_21 AC 470 ms
4,376 KB
testcase_22 AC 528 ms
4,376 KB
testcase_23 AC 456 ms
4,376 KB
testcase_24 AC 517 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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