zoukankan      html  css  js  c++  java
  • 2016D1T1 玩具谜题

    2016D1T1 玩具迷题

    problem&solution

    注意下标从0开始,否则模的时候会出现5%5=0这类情况。异或会使得特判少很多。

    code

    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    using namespace std;
    int read(){
    	int a=0,op=1;char c=getchar();
    	while(c>'9'||c<'0') {if(c=='-') op=-1;c=getchar();}
    	while(c>='0'&&c<='9'){a*=10,a+=c^48,c=getchar();}
    	return a*op;
    }
    const int maxn=1e5+10;
    int n,m;
    char s[maxn][20];
    int pos[maxn];//0 nei 1 wai
    int main(){
    	n=read(),m=read();
    	for(int i=0;i<n;i++) scanf("%d %s",&pos[i],s[i]);
    	int cur=0;
    	for(int i=1;i<=m;i++){
    		int a,b;
    		a=read(),b=read();//0 left 1 right
    		if(a^pos[cur]==1) cur=(cur+b)%n;
    		else cur=((cur-b)%n+n)%n;
    	}
    	printf("%s",s[cur]);
    	return 0;
    }
    
  • 相关阅读:
    密码学浅析
    FireWall Mark + LVS
    tcp/ip首部
    iptables(二)网络防火墙
    BIND服务
    LVS(一)
    QQ、微信消息轰炸
    LVS四种模型(二)
    安装和克隆
    压缩和打包
  • 原文地址:https://www.cnblogs.com/liuziwen0224/p/2016d1t1.html
Copyright © 2011-2022 走看看