結果
| 問題 |
No.2479 Sum of Squares
|
| コンテスト | |
| ユーザー |
kekenx
|
| 提出日時 | 2024-01-09 17:38:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 733 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 85,552 KB |
| 最終ジャッジ日時 | 2025-02-18 16:48:57 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 22 |
ソースコード
#include <iostream>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long S; cin >> S;
vector<long long> ans = { S };
auto is_square = [](long long x) -> bool {
long long y = (long long)sqrtl((long double)x);
return y * y == x;
};
while (!is_square(ans.back())) {
long long x = (long long)sqrtl((long double)ans.back());
long long nxt = ans.back() - x * x;
ans.back() = x * x;
ans.push_back(nxt);
}
assert(ans.size() <= 15);
long long s = 0;
for (int i = 0; i < ans.size(); i++) {
s += ans[i];
cout << ans[i] << (i + 1 == ans.size()? "\n": " ");
}
assert(s == S);
return 0;
}
kekenx