結果

問題 No.2479 Sum of Squares
ユーザー twooimp2
提出日時 2023-11-29 22:10:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 389 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 194,984 KB
最終ジャッジ日時 2025-02-18 02:25:00
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll s;
  cin>>s;
  vector<ll> ans;
  while(s!=0){
    ll ok=0,ng=s+1;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(mid*mid<=s){
        ok=mid;
      }else{
        ng=mid;
      }
    }
    s-=ok*ok;
    ans.push_back(ok*ok);
  }
  cout<<ans.size()<<endl;
  for(ll u:ans){
    cout<<u<<" ";
  }
}
0