結果

問題 No.1929 Exponential Sequence
ユーザー 沙耶花沙耶花
提出日時 2022-05-06 21:42:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 4,607 ms
コンパイル使用メモリ 263,760 KB
実行使用メモリ 23,508 KB
最終ジャッジ日時 2023-10-12 04:19:38
合計ジャッジ時間 5,890 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 117 ms
22,512 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 1 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,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,352 KB
testcase_21 AC 122 ms
23,508 KB
testcase_22 AC 78 ms
12,960 KB
testcase_23 AC 120 ms
23,112 KB
testcase_24 AC 56 ms
13,300 KB
testcase_25 AC 120 ms
22,864 KB
testcase_26 AC 122 ms
22,584 KB
testcase_27 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

long long S;

void get(vector<long long> a,vector<long long> &t,int c,long long s){
	if(a.size()==c){
		t.push_back(s);
		return;
	}
	long long tt = 1;
	rep(i,30){
		if(s+tt>S)break;
		if(i!=0)get(a,t,c+1,s+tt);
		tt *= a[c];
	}
}

int main(){
	
	int n;
	cin>>n;
	
	cin>>S;
	
	vector<long long> a(n);
	rep(i,n)cin>>a[i];
	
	vector<long long> b;
	while(a.size()>b.size()){
		b.push_back(a.back());
		a.pop_back();
	}
	vector<long long> x,y;
	get(a,x,0,0);
	get(b,y,0,0);
	
	sort(x.begin(),x.end());
	long long ans = 0;
	rep(i,y.size()){
		ans += distance(x.begin(),lower_bound(x.begin(),x.end(),S-y[i]+1));
	}
	cout<<ans<<endl;
	
    return 0;
}
0