結果

問題 No.1929 Exponential Sequence
ユーザー tailstails
提出日時 2022-05-06 23:24:04
言語 cLay
(20231016-1)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 2,563 ms
コンパイル使用メモリ 169,220 KB
実行使用メモリ 7,024 KB
最終ジャッジ日時 2023-10-12 04:23:17
合計ジャッジ時間 3,793 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 35 ms
6,984 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 33 ms
6,968 KB
testcase_22 AC 21 ms
5,800 KB
testcase_23 AC 32 ms
6,872 KB
testcase_24 AC 14 ms
5,160 KB
testcase_25 AC 32 ms
6,980 KB
testcase_26 AC 34 ms
7,024 KB
testcase_27 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll n,s;
map<ll,ll> f(ll n){
	map<ll,ll>src,dst;
	src[0]=1;
	rep(n){
		ll@a;
		for(auto t:src){
			for(ll b=a;t.first+b<=s;b*=a){
				dst[t.first+b]+=t.second;
			}
		}
		swap(src,dst);
		dst.clear();
	}
	return src;
}
{
	rd(n,s);
	auto z1=f(n/2);
	auto z2=f(n-n/2);
	ll m=0,z=0,y=0;
	auto t1=z1.begin();
	auto t2=z2.rbegin();
	for(;t2!=z2.rend();){
		if(t1!=z1.end() && t1->first+t2->first<=s){
			m+=t1->second;
			++t1;
		}
		else{
			z+=m*t2->second;
			++t2;
		}
	}
	wt(z);
}

0