結果
問題 | No.2479 Sum of Squares |
ユーザー |
|
提出日時 | 2023-09-22 21:30:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 4,124 ms |
コンパイル使用メモリ | 252,420 KB |
最終ジャッジ日時 | 2025-02-17 00:24:06 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll=long long;ll ll_square_root(ll x){ll l=1,r=1000000001;while(l+1<r){ll c=(l+r)/2;if(c*c<=x)l=c;else r=c;}return l;}int main(){ll s;cin>>s;vector<ll> a;while(true){ll k=ll_square_root(s);while(s>=k*k){s-=k*k;a.push_back(k*k);}if(s==0)break;}int m=a.size();cout<<m<<endl;for(int i=0;i<m-1;i++)cout<<a[i]<<" ";cout<<a[m-1]<<endl;return 0;}