UVa 10404 - Bachet's Game
2013-06-16 10:25
453 查看
/* DP: 假设可取石子数为1,3。 若总共1或3个石子,则先拿的人必胜。 若总共2、4个石子先拿的人必败。 若5个石子,则先拿的人取1个石子,则必胜 ... */ #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const int MAXN = 1000005; const int MAXM = 15; int n, m; int A[MAXM]; int d[MAXN]; int main(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif while(scanf("%d%d", &n, &m) == 2) { for(int i=0; i<m; i++) { scanf("%d", &A[i]); } d[0] = 0; for(int i=1; i<=n; i++) { int found = 0; for(int j=0; j<m; j++) { if(i >= A[j] && !d[i-A[j]]) { d[i] = 1; found = 1; break; } } if(!found) d[i] = 0; } if(d ) printf("Stan wins\n"); else printf("Ollie wins\n"); } return 0; }
相关文章推荐
- uva10404 - Bachet's Game(博弈,递推)
- uva 10404 - Bachet's Game
- UVA10404- Bachet's Game
- Uva 10404-Bachet's Game(博弈)
- uva 10404 Bachet's Game (完全背包+博弈)
- UVA 题目10404 - Bachet's Game(DP+博弈)
- UVA 10404 - Bachet's Game 组合博弈
- UVA - 10404 Bachet's Game
- UVA - 10404 Bachet's Game
- UVA 10404 Bachet's Game
- UVA - 10404 Bachet's Game 博弈
- UVA 10404 Bachet's Game
- uva 10404 Bachet's Game
- dp+博弈 uva-10404-Bachet's Game
- UVa 10404 Bachet's Game (DP&博弈)
- uva 10404 Bachet's Game
- UVA 10404 Bachet's Game
- uva 10404 Bachet's Game(dp 博弈)
- Bachet's Game - UVa 10404 dp博弈论
- Uva-10404-Bachet's Game