逃跑路线

逃跑路线

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;
}
全部评论

相关推荐

是每个人事都这样与找工作的人这样沟通吗?正常询问不可以吗
超时空记忆丶:这种人适合跟我聊 我能骂得她心里难受一天,这种byd一看就是欠骂,这么好的机会楼主别错过。
点赞 评论 收藏
分享
05-09 13:22
门头沟学院 Java
点赞 评论 收藏
分享
喜欢飞来飞去的雪碧在刷代码:可以试一试字节
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务