結果

問題 No.2479 Sum of Squares
ユーザー t98slidert98slider
提出日時 2023-10-09 23:17:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 167,356 KB
実行使用メモリ 814,668 KB
最終ジャッジ日時 2023-10-09 23:17:21
合計ジャッジ時間 5,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll v;
    cin >> v;
    auto sq = [&](ll v){
        ll res = sqrtl(v) + 5;
        while(res * res > v) res--;
        return res;
    };
    vector<ll> ans;
    while(v){
        ans.push_back(sq(v));
        v -= ans.back();
    }
    cout << ans.size() << '\n';
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
    }
}
0