結果
| 問題 | No.2479 Sum of Squares |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 15:56:25 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 581 bytes |
| 記録 | |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 91,728 KB |
| 実行使用メモリ | 9,156 KB |
| 最終ジャッジ日時 | 2026-07-05 02:38:40 |
| 合計ジャッジ時間 | 1,667 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
long long S, l, c, r;
vector<long long> ans;
cin >> S;
while (S != 0)
{
for (l = 1, r = 1'000'000'001; l + 1 < r; )
{
c = (l + r) / 2;
if (c * c <= S) l = c;
else r = c;
}
ans.push_back(l * l);
S -= l * l;
}
cout << ans.size() << '\n' << ans[0];
for (int i = 1; i != ans.size(); ++i) cout << ' ' << ans[i];
cout << '\n';
return 0;
}