結果
| 問題 |
No.2479 Sum of Squares
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-22 21:27:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 560 bytes |
| コンパイル時間 | 638 ms |
| コンパイル使用メモリ | 75,952 KB |
| 実行使用メモリ | 814,848 KB |
| 最終ジャッジ日時 | 2024-07-08 12:08:02 |
| 合計ジャッジ時間 | 2,336 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | MLE * 1 -- * 21 |
ソースコード
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
using namespace std;
long sq(long N)
{
long r=sqrt(N);
while((r+1)*(r+1)<=N)r++;
return r;
}
vector<long>solve(long N)
{
if(N==0)return{};
long t=sq(N);
vector<long>A=solve(N-t*t);
A.push_back(t*t);
if(t>1)
{
t--;
vector<long>B=solve(N-t*t);
B.push_back(t*t);
if(A.size()>B.size())A=B;
}
return A;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
long S;
cin>>S;
vector<long>A=solve(S);
cout<<A.size()<<endl;
for(long v:A)cout<<v<<" ";
cout<<endl;
}