Untitled
unknown
plain_text
a year ago
1.1 kB
10
Indexable
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int mod = 1e9 + 7;
const int INF = 1e18 + 5;
const double PI = 3.1415926535;
const double eps = 1e-9;
int n, k;
vector<int> a(101), dp(100001,-1);
int rec(int stone) {
if (stone == 0) {
return 0;
}
if (dp[stone] != -1) {
return dp[stone];
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (stone - a[i] >= 0 && rec(stone - a[i]) == 0) {
ans = 1;
break;
}
}
return dp[stone] = ans;
}
void solve() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (rec(k)) {
cout << "First" << endl;
} else {
cout << "Second" << endl;
}
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Editor is loading...
Leave a Comment