結果
問題 | No.2479 Sum of Squares |
ユーザー |
|
提出日時 | 2023-10-09 23:19:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 1,734 ms |
コンパイル使用メモリ | 169,844 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-12 21:46:32 |
合計ジャッジ時間 | 2,751 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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 * 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' : ' ');}}