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
四个方向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; }
相关文章推荐
- codeforces 834-A. The Useless Toy
- Codeforces 834 A The Useless Toy
- Codeforces 834A-The Useless Toy
- 【CodeForces】426Div2 A The Useless Toy
- Codeforces 843A:The Useless Toy
- Codeforces 834A - The Useless Toy
- A. The Useless Toy
- Codeforces Round #426 (Div. 2) The Useless Toy 数组环
- Codeforces 834 C The Meaningless Game(二分)
- Codeforces Round #426 (Div. 2) A The Useless Toy
- The Useless Toy
- A. The Useless Toy
- (模拟)Codeforces Round #426 A. The Useless Toy
- CF 834A-The Useless Toy
- CodeForces 834 B.The Festive Evening(水~)
- H - The Child and Toy-CodeForces 437C-水题
- cfThe Useless Toy(水)
- Codeforces Round #426 (Div. 2) A. The Useless Toy
- Codeforces Round #426 (Div. 2) A The Useless Toy
- codeforces 834 C The Meaningless Game