BZOJ 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
2014-07-10 23:14
691 查看
一开始被题意坑了= =,题目是说这个数字的最大和最小,不是个位的最大和最小= =
不知道怎么做只能递推了,必胜态就是存在能到达必败态的,必败态就是只能到达必胜态的
CODE:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000000
bool b[MAX+2];
int solve(){
for (int i=1;i<=9;i++) b[i]=1;
for (int i=10;i<=MAX;i++){
int ma=0,mi=10,t=i;
while (t){
ma=max(t%10,ma);
mi=t%10==0?mi:min(mi,t%10);
t/=10;
}
b[i]=!(b[i-mi]&b[i-ma]);
}
}
int main(){
int t,n;
scanf("%d",&t);
solve();
while (t--) {
scanf("%d",&n);
if (b
) printf("YES\n");
else printf("NO\n");
}
return 0;
}
不知道怎么做只能递推了,必胜态就是存在能到达必败态的,必败态就是只能到达必胜态的
CODE:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000000
bool b[MAX+2];
int solve(){
for (int i=1;i<=9;i++) b[i]=1;
for (int i=10;i<=MAX;i++){
int ma=0,mi=10,t=i;
while (t){
ma=max(t%10,ma);
mi=t%10==0?mi:min(mi,t%10);
t/=10;
}
b[i]=!(b[i-mi]&b[i-ma]);
}
}
int main(){
int t,n;
scanf("%d",&t);
solve();
while (t--) {
scanf("%d",&n);
if (b
) printf("YES\n");
else printf("NO\n");
}
return 0;
}
相关文章推荐
- 【BZOJ】3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
- 【博弈论】【SG函数】bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(SG函数)
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 (博弈论)
- 【BZOJ】【3404】【USACO2009 Open】Cow Digit Game又见数字游戏
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- [bzoj3404] [Usaco2009 Open]Cow Digit Game又见数字游戏
- [BZOJ3404][Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
- BZOJ_P1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(hhhhhh)
- 【BZOJ】1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【bzoj1666】 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【BZOJ】1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(刷水严重)
- bzoj1666[Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏【模拟】