結果
問題 | No.2479 Sum of Squares |
ユーザー |
|
提出日時 | 2023-09-22 21:46:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 2,093 ms |
コンパイル使用メモリ | 196,052 KB |
最終ジャッジ日時 | 2025-02-17 00:32:20 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);ll S;cin>>S;vector ans(0,0ll);while(S>0){ll ok=1,ng=1e9;while(ng-ok>1){ll mid=(ok+ng)/2;if(mid*mid<=S)ok=mid;else ng=mid;}ans.push_back(ok*ok);S-=ok*ok;}cout<<ans.size()<<'\n';for(int i=0;i<ans.size();i++){cout<<ans[i]<<" \n"[i==ans.size()-1];}}