题解 | #智乃的箭头魔术#

智乃的二进制

https://ac.nowcoder.com/acm/contest/120565/A

alt

代码演示:

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
const int N = 500010;

void solve(){
	int f=0;
	string s="0112233445142015320125410214530214510214102302142025101203201451451522302514203214510021454101002532";
	for(int i=0;i<s.length();i++){
		if(s[i]=='0'){
			f=3-f;
		}else if(s[i]=='1'){
			if(f%2==1){
                f=4-f;
            }
		}else if(s[i]=='2'){
			f=f^1;
		}else if(s[i]=='3'){
			if(f==0) f=2;
			else if(f==2) f=0;
		}else if(s[i]=='4'){
			f=(f+1)%4;
		}else{
			f=(f+3)%4;
		}
		cout<<f;
	}
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	int T=1;//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}
全部评论

相关推荐

累死的一条狗:***一人顶10人那你给我发10个人的工资总和吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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