uva_10404_Bachet's Game
2012-11-09 14:18
447 查看
这道题居然卡了一天,自愧。 状态:dp[i]表示在数为i的时候先下的那个人是否输赢 状态转移:dp[i] 前的状态dp[j]能否到达dp[i],若能而且 dp[j] = 0, dp[i] = 1,则表示第n开始的时候第一人可以有必胜的把握 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define MAXVAL 11 #define MAXN 1000001 int dp[MAXN], val[MAXVAL], flag, m; int sure_win(const int &n) { memset(dp, 0, sizeof(int)*(n+1)); dp[0] = 0; for(int i = 0; i <= n; i ++) { for(int j = 0; j < m; j ++) { if( i < val[j] || dp[i] ) { continue; } if( !dp[i-val[j]] ) { dp[i] = 1; } } } return dp ; } int main(int argc, char const *argv[]) { #ifndef ONLINE_JUDGE freopen("test.in", "r", stdin); #endif int n; while( ~scanf("%d %d", &n, &m) ) { for(int i = 0; i < m; i ++) { scanf("%d", &val[i]); } if ( sure_win(n) ) { printf("Stan wins\n"); continue; } printf("Ollie wins\n"); } return 0; }
相关文章推荐
- uva10404 - Bachet's Game(博弈,递推)
- UVA10404- 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 博弈
- 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(DP+博弈)
- uva 10404 Bachet's Game(dp 博弈)
- UVa 10404 - Bachet's Game 博弈+动态规划
- Bachet's Game - UVa 10404 dp博弈论
- Uva-10404-Bachet's Game