题意:如下图字符的变换
现在给你初始的字符和旋转n次的字符,问你,它是顺时针还是逆时针或者是其他
思路:4为循环节,先保存好顺时针和逆时针的字符顺序,然后判断初始的时候字符在第几个,再让初始字符回到第0的位置(关于循环节的问题一般直接模循环节然后从0开始标序号)
AC代码:
#include "iostream" #include "string.h" #include "stack" #include "queue" #include "string" #include "vector" #include "set" #include "map" #include "algorithm" #include "stdio.h" #include "math.h" #pragma comment(linker, "/STACK:102400000,102400000") #define ll long long #define bug(x) cout<<x<<" "<<"UUUUU"<<endl; #define mem(a,x) memset(a,x,sizeof(a)) #define mp(x,y) make_pair(x,y) #define pb(x) push_back(x) #define lrt (rt<<1) #define rrt (rt<<1|1) using namespace std; const long long INF = 1e18+1LL; const int inf = 1e9+1e8; const int N=1e6+100; const ll mod=1e9+7; char s,e,s1[5]=">v<^",s2[5]="^<v>"; int n; int main(){ cin>>s>>e>>n; int k1=n, k2=n; for(int i=0; i<=3; ++i){ if(s==s1[i]){ k1+=i; break; } } for(int i=0; i<=3; ++i){ if(s==s2[i]){ k2+=i; break; } } k1%=4, k2%=4; if(s1[k1]==e && s2[k2]!=e){ cout<<"cw "; return 0; } if(s2[k2]==e && s1[k1]!=e){ cout<<"ccw "; return 0; } else cout<<"undefined "; return 0; }