結果
問題 | No.1929 Exponential Sequence |
ユーザー |
![]() |
提出日時 | 2022-05-06 21:42:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 4,372 ms |
コンパイル使用メモリ | 254,356 KB |
最終ジャッジ日時 | 2025-01-29 03:22:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 |
ソースコード
#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; }