結果
問題 | No.1929 Exponential Sequence |
ユーザー |
![]() |
提出日時 | 2025-02-01 15:45:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 588 bytes |
コンパイル時間 | 4,832 ms |
コンパイル使用メモリ | 84,256 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2025-02-01 15:45:58 |
合計ジャッジ時間 | 23,777 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 TLE * 1 |
other | WA * 18 TLE * 6 |
ソースコード
#include <iostream>#include <vector>using namespace std;typedef long long ll;int n;ll S;vector<ll> a;ll countSolutions = 0;void dfs(int index, ll sum) {if (sum > S) return; // 制約超えなら終了if (index == n) {countSolutions++;return;}ll power = 1;while (sum + power <= S) {dfs(index + 1, sum + power);power *= a[index];}}int main() {cin >> n >> S;a.resize(n);for (int i = 0; i < n; i++) {cin >> a[i];}dfs(0, 0);cout << countSolutions << endl;return 0;}