逃跑路线
逃跑路线
https://ac.nowcoder.com/acm/contest/6874/J
题面关键信息:横坐标&(2^1-1)&(2^2-1)&…&(2^n-1),实际上在&(2^1-1)时后面位数的值就不需要考虑了,我们只需要算出答案的奇偶性即可
#include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdio> #include<cmath> #define LL long long using namespace std; const int INF=0x3f3f3f3f; int read() { int s=0,bj=0; char ch=getchar(); while(ch<'0'||ch>'9')bj|=(ch=='-'),ch=getchar(); while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+(ch^48),ch=getchar(); return bj?-s:s; } void printnum(int x) { if(x>9)printnum(x/10); putchar(x%10^48); } void print(int x,char ch) { if(x<0){putchar('-');x=-x;} printnum(x);putchar(ch); } int n; int len; char ch[10005]; int num; int main() { n=read(); for(int i=1;i<=n;++i) { scanf("%s",ch+1);len=strlen(ch+1); num=(num+ch[len]-'0')%2;//加上这一个数的最后一位 } print(num,'\n'); return 0; }