HDU 4371 Alice and Bob
比赛是木做出来,回头看看,是当时考虑的太复杂了,si = si-1 + dk or si = si-1 - dk , and si-2 < si<= n, 1 <= k <= m, i >= 3相减的不会去取,每次都加上个d
View Code
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int main() 5 { 6 int i, k, d, ncases; 7 int n, m, dmin; 8 9 scanf("%d", &ncases); 10 for(k = 1; k <= ncases; k++) 11 { 12 scanf("%d%d",&n,&m); 13 for(i=0; i<m; i++) 14 { 15 scanf("%d",&d); 16 if(i) 17 dmin = d < dmin ? d : dmin; 18 else 19 dmin = d; 20 } 21 n = n/dmin; 22 printf("Case #%d: ",k); 23 if((n+1)%2 == 0) 24 printf("Bob\n"); 25 else 26 printf("Alice\n"); 27 } 28 system("pause"); 29 return 0; 30 }
min,
只要拿n/dmin+1判断结果是奇数还是偶数就可以了。当是奇数时,最后一个取数的一定是Bob,因为是Alice先去的,所以此时Bob赢。反之一定是Alice赢