結果

問題 No.2479 Sum of Squares
ユーザー 乾麺乾麺
提出日時 2024-04-03 13:54:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 912 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 192,228 KB
実行使用メモリ 141,856 KB
最終ジャッジ日時 2024-04-03 13:55:04
合計ジャッジ時間 6,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using si =vector<char>;
using ssi =vector<si>;
//using mint = modint998244353;
const long long INF = 1e18;
//bit全探索 rep(i,0,1<<(n-1)){rep(j,0,n-1)if(I&(1<<j))}
//int a = s[0] - ‘0’;文字列から数字
//int a=atoi(s.c_str());
//“ABCDEFGHIJKLMNOPQRSTUVWXYZ"
//ll l-=-1,r=2e9;
//while (r - l > 1) {
//    ll m = (l + r) / 2;
//    (m * (m + 1) / 2 <= n + 1 ? l : r) = m;
//  }
int main() { ll s;
cin>>s;
ll n=s;
vi vec;
while(n>0){

	ll l=-1;
	ll r=2*n;
	while(r-l>1){
		ll m=(l+r)/2;
		(m*m<=n ? l:r)=m;
	}
	vec.push_back(l*l);
	n-=l*l;
	
}int m=vec.size();
cout<<m<<endl;
rep(i,0,m){cout<<vec[i]<<" ";}
}
0