zoukankan      html  css  js  c++  java
  • A New Stone Game

    其实我们发现,只要面对的糖堆相同的有偶数个就一定会输。因为你取什么,对方就取对应的什么,最后一个总是对方取的。而且你无法改变此局面,因为若将糖分割,对面可以将糖又加回相等的情况。(可以任意去掉糖果)

    #include<cstdio>
    #include<algorithm>
    using namespace std;
    
    int n, m, a[12];
    
    int read() {
    	int x = 0, f = 1; char s;
    	while((s = getchar()) > '9' || s < '0') {
    		if(s == '-') f = -1;
    		if(s == EOF) exit(0);
    	}
    	while(s >= '0' && s <= '9') {
    		x = (x << 1) + (x << 3) + (s ^ 48);
    		s = getchar();
    	}
    	return x * f;
    }
    
    int main() {
    	bool flag;
    	while(n = read(), n) {
    		flag = 0;
    		for(int i = 1; i <= n; ++ i) a[i] = read();
    		if(n & 1) {puts("1"); continue;}
    		for(int i = 1; i <= n; i += 2)
    			if(a[i] != a[i + 1]) {flag = 1; break;}
    		puts(flag ? "1" : "0");
    	}
    	return 0;
    }
    
  • 相关阅读:
    HDU
    POJ
    POJ
    POJ
    POJ
    POJ
    POJ
    SPFA算法——最短路径
    POJ1251 Jungle Roads Kruskal+scanf输入小技巧
    MongoDB--关于数据库及选择MongoDB的原因
  • 原文地址:https://www.cnblogs.com/AWhiteWall/p/12334392.html
Copyright © 2011-2022 走看看