您的位置:首页 > 其它

CodeForces 834 A.The Useless Toy(水~)

2017-07-31 13:59 405 查看
Description

四个方向V,<,^,>,每次旋转可以选择一个方向,然后旋转一次是90度,现在给出两个方向和旋转的次数,保证往某个方向旋转可以从第一个方向到达第二个方向,问旋转方向

Input

两个字符表示两个方向,之后一整数n表示旋转次数(0<=n<=1e9)

Output

如果只能顺时针转过去则输出cw,如果只能逆时针转过去则输出ccw,如果两个方向都可以转过去则输出undefined

Sample Input

^ >

1

Sample Output

cw

Solution

给四个方向依次编个号0,1,2,3,第一个编号加个n模4后如果是第二个编号说明是顺时针,减个n模4后如果是第二个编号说明是逆时针

Code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=100001;
int get(char c)
{
if(c=='v')return 0;
if(c=='<')return 1;
if(c=='^')return 2;
if(c=='>')return 3;
}
int main()
{
char a[3],b[3];
int n;
while(~scanf("%s%s%d",a,b,&n))
{
int x=get(a[0]),y=get(b[0]);
int f1=0,f2=0;
if((x+n)%4==y)f1=1;
if(((x-n)%4+4)%4==y)f2=1;
if(f1&&f2)printf("undefined\n");
else if(f1)printf("cw\n");
else printf("ccw\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: