Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这题有什么好消元和搜索的啊……只要枚举第一个碗翻不翻,后面的每一个都是确定的。 O(1)的枚举量嘛~ #include <iostream> using namespace std; int bowl[25]={0},flip[25]={0}; int main() { int i,cnt=100,tmp; for (i=1;i<21;i++) cin >> bowl[i]; flip[1] = tmp = 1; //翻第一个 for (i=2;i<21;i++) if ( flip[i] = (flip[i-2]^flip[i-1]^bowl[i-1]) ) tmp++; if ( tmp<cnt && (flip[19]^flip[20]^bowl[20])==0 ) cnt = tmp; flip[1] = tmp = 0; //不翻第一个 for (i=2;i<21;i++) if ( flip[i] = (flip[i-2]^flip[i-1]^bowl[i-1]) ) tmp++; if ( tmp<cnt && (flip[19]^flip[20]^bowl[20])==0 ) cnt = tmp; cout << cnt << endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator