結果
| 問題 | 
                            No.2479 Sum of Squares
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-09-22 21:46:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 536 bytes | 
| コンパイル時間 | 1,504 ms | 
| コンパイル使用メモリ | 196,792 KB | 
| 最終ジャッジ日時 | 2025-02-17 00:32:44 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / 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];
}