Codeforces Round #426 (Div. 2) - A
题目链接:http://codeforces.com/contest/834/problem/A
题意:给定4个图标,某些图标经过顺时针/逆时针旋转90°后能得到另外一些图标。现在给你开始的图标和结束的图标,还有旋转的次数n。问你开始图标经过n次旋转后得到结束图标的旋转方向是顺时针还是逆时针还是无法确定。
思路:水题,可以发现每个图标经过4次旋转后(顺/逆时针一样)会回到原来的位置,那么我们先对n%4,然后就可以暴力枚举(枚举次数<4)顺时针和逆时针得到的结果了。然后和结束图标来匹配最终确定旋转方向。
#define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<queue> #include<vector> #include<time.h> #include<cmath> #include<set> #include<map> using namespace std; typedef long long int LL; const int MAXN = 1e5 + 24; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; char cw[5]; int main(){ #ifdef kirito freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif char c1[2],c2[2]; int n; cw[0] = 'v'; cw[1] = '<'; cw[2] = '^'; cw[3] = '>'; while (~scanf("%s %s", c1,c2)){ scanf("%d", &n); n %= 4; int res = -1,cnt=0; for (int i = 0,j,k; i <= 3; i++){ if (c1[0] == cw[i]){ for (k = 1, j = i; k <= n; k++, j = (j + 1 == 4 ? 0 : j + 1)){ } if (c2[0] == cw[j]){ res = 0; cnt++; } break; } } for (int i = 3,j,k; i >= 0; i--){ if (c1[0] == cw[i]){ for (k = 1, j = i; k <= n; k++, j = (j - 1 == -1 ? 3 : j - 1)){} if (c2[0] == cw[j]){ res = 1; cnt++; } break; } } if (res == 0&&cnt==1){ printf("cw\n"); } else if (res == 1&&cnt==1){ printf("ccw\n"); } else{ printf("undefined \n"); } } return 0; }