結果

問題 No.2479 Sum of Squares
ユーザー coco0715coco0715
提出日時 2023-09-22 21:45:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,105 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 166,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 21:45:59
合計ジャッジ時間 9,765 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1,105 ms
4,376 KB
testcase_04 AC 364 ms
4,376 KB
testcase_05 AC 209 ms
4,380 KB
testcase_06 AC 252 ms
4,376 KB
testcase_07 AC 240 ms
4,380 KB
testcase_08 AC 313 ms
4,380 KB
testcase_09 AC 267 ms
4,380 KB
testcase_10 AC 296 ms
4,376 KB
testcase_11 AC 270 ms
4,376 KB
testcase_12 AC 302 ms
4,376 KB
testcase_13 AC 196 ms
4,380 KB
testcase_14 AC 254 ms
4,380 KB
testcase_15 AC 255 ms
4,376 KB
testcase_16 AC 277 ms
4,376 KB
testcase_17 AC 266 ms
4,380 KB
testcase_18 AC 254 ms
4,376 KB
testcase_19 AC 285 ms
4,380 KB
testcase_20 AC 280 ms
4,376 KB
testcase_21 AC 237 ms
4,376 KB
testcase_22 AC 265 ms
4,380 KB
testcase_23 AC 229 ms
4,380 KB
testcase_24 AC 282 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <math.h>
//ここから省略
#define yes (cout<<"Yes"<<endl)
#define no (cout<<"No"<<endl)
using namespace std;

int main(){
long long n,a;cin>>n;
vector<long long> b;a=sqrt(n);
for(long long i=a;i>0;i--){
    while(n>=i*i){
        b.push_back(i*i);
        n-=i*i;
    }
    if(n==0)break;
    //cout<<i<<':'<<n<<endl;
}
cout<<b.size()<<endl;
for(long long x:b)cout<<x<<' ';
cout<<endl;
}
0