傻瓜自助建站软件,怎样进网站空间服务器,知名网站建设推荐,网站标签名词题意#xff1a;给定一个长度为n的灯泡的状态序列#xff0c;经过每个灯泡时#xff0c;都要开关一下#xff08;开变关#xff0c;关变开#xff09;#xff0c;问能否在回到终点的条件下关掉所有的灯。 思路#xff1a;没出现一个为1的灯#xff0c;都需要走奇数步来…题意给定一个长度为n的灯泡的状态序列经过每个灯泡时都要开关一下开变关关变开问能否在回到终点的条件下关掉所有的灯。 思路没出现一个为1的灯都需要走奇数步来关掉它而灯的总数为奇数的时候才能走奇数步偶数同理。那么总数和1的个数同奇同偶时为YES。 code #include cstdio
#include iostream
#include algorithm
#include string
#include cstring
#include cmath
#include set
#include queue
#include map
using namespace std;#define ft(i,s,t) for (int is;it;i)
#define cls(a,c) memset(a,c,sizeof(a))
typedef long long ll;
const int N1000006;
const int M105;int main()
{int T;scanf(%d,T);while (T--){int s0,t,n;scanf(%d,n);ft(i,1,n) {scanf(%d,t);if (t1) s;}if (n%2s%2) puts(YES);else if (n%20s%20) puts(YES);else puts(NO);}
}