Codeforces Round #426 (Div. 2)A. The Useless Toy

题意:4个箭头,给出起始箭头,终始箭头,问经历n次,是由顺时针cw得到,还是逆时针cww得到,如果都可以输出undefined

思路:n%4,就是次数了,再两个方向模拟下

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int N=1e5+10;
 5 
 6 int a[6]={0,1,2,3,4};
 7 int main(){
 8     int n;
 9     char s1[2],s2[2];
10     scanf("%s%s",s1,s2);
11     scanf("%d",&n);
12     int l,r;
13     if(s1[0]=='^') l=1;
14     else if(s1[0]=='>') l=2;
15     else if(s1[0]=='v') l=3;
16     else if(s1[0]=='<') l=4;
17     if(s2[0]=='^') r=1;
18     else if(s2[0]=='>') r=2;
19     else if(s2[0]=='v') r=3;
20     else if(s2[0]=='<') r=4;
21     int s=0;
22     n=n%4;
23     int ll=l,rr=l;
24     int ss1=0;
25     int ss2=0;
26     if(((ll+n)%4)==r%4){
27        ss1=1;
28     }
29     if(((l-n+4)%4)==r%4)
30         ss2=1;
31     if(ss1&&ss2){
32         cout<<"undefined"<<endl;
33     }
34     else if(ss1){
35         cout<<"cw"<<endl;
36     }
37     else
38         cout<<"ccw"<<endl;
39 }

 

posted on 2017-07-31 12:12  hhhhx  阅读(114)  评论(0编辑  收藏  举报

导航