結果
| 問題 |
No.2479 Sum of Squares
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-22 21:33:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 490 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 75,796 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 12:15:24 |
| 合計ジャッジ時間 | 1,801 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#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++;
while(r*r>N)r--;
return r;
}
vector<long>solve(long N,int d)
{
if(N==0)return{};
long t=sq(N);
vector<long>A=solve(N-t*t,d+1);
A.push_back(t*t);
return A;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
long S;
cin>>S;
vector<long>A=solve(S,0);
cout<<A.size()<<endl;
for(long v:A)cout<<v<<" ";
cout<<endl;
}