【POJ 2975】Nim

题目传送门:http://poj.org/problem?id=2975

最开始一直在想,怎么优化DP
然而后来发现,这TM只求有效的第一步有几种走法QAQ

#include<iostream>
#include<cstdio>
using namespace std;

const int MAXN = 1000+9;

int arr[MAXN],n,sta,vout; 

int main(){
	while (cin>>n && n) { 
		sta = vout = 0;
		for (int i=1;i<=n;i++) cin>>arr[i], sta ^= arr[i];
		if (sta) for (int i=1;i<=n;i++) {
			sta ^= arr[i]; 
			if (sta < arr[i]) vout++;
			sta ^= arr[i];
		}
		printf("%d\n",vout);
	}
	return 0;
}

14 thoughts to “【POJ 2975】Nim”

  1. 90318 682937Youre so cool! I dont suppose Ive read anything like this before. So nice to search out any individual with some original thoughts on this subject. realy thank you for starting this up. this website is one thing thats wanted on the web, somebody with a bit of originality. helpful job for bringing something new towards the internet! 862838

  2. 792231 588538I enjoyed reading this a lot I really hope to read more of your posts inside the future, so Ive bookmarked your blog. But I couldnt just bookmark it, oh no.. When I see quality websites like this one, I like to share it with other people So Ive developed a backlink to your web site (from 930924

Leave a Reply

Your email address will not be published. Required fields are marked *