結果
問題 | No.2479 Sum of Squares |
ユーザー | karinohito |
提出日時 | 2023-09-22 21:46:32 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 204,080 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-08 12:31:02 |
合計ジャッジ時間 | 3,075 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; ll sqrtz(ll N) { ll L = 0; ll R = sqrt(N) + 10000; while (abs(R - L) > 1) { ll mid = (R + L) / 2; if (mid * mid <= N)L = mid; else R = mid; } return L; } int main() { ll N; cin>>N; vector<ll> AN; while(N>0){ ll z=sqrtz(N); AN.push_back(z*z); N-=z*z; } N=AN.size(); cout<<N<<endl; for(ll i=0;i<N;i++)cout<<AN[i]<<" \n"[i==N-1]; }