16CF1-A
来源:互联网 发布:淘宝美工如何上新 编辑:程序博客网 时间:2024/06/04 08:12
Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strange contraption.
Spinners in Sweetland have the form of V-shaped pieces of caramel. Each spinner can, well, spin around an invisible magic axis. At a specific point in time, a spinner can take 4 positions shown below (each one rotated 90 degrees relative to the previous, with the fourth one followed by the first one):
After the spinner was spun, it starts its rotation, which is described by a following algorithm: the spinner maintains its position for a second then majestically switches to the next position in clockwise or counter-clockwise order, depending on the direction the spinner was spun in.
Slastyona managed to have spinner rotating for exactly n seconds. Being fascinated by elegance of the process, she completely forgot the direction the spinner was spun in! Lucky for her, she managed to recall the starting position, and wants to deduct the direction given the information she knows. Help her do this.
There are two characters in the first string – the starting and the ending position of a spinner. The position is encoded with one of the following characters: v (ASCII code 118, lowercase v), < (ASCII code 60), ^ (ASCII code 94) or > (ASCII code 62) (see the picture above for reference). Characters are separated by a single space.
In the second strings, a single number n is given (0 ≤ n ≤ 109) – the duration of the rotation.
It is guaranteed that the ending position of a spinner is a result of a n second spin in any of the directions, assuming the given starting position.
Output cw, if the direction is clockwise, ccw – if counter-clockwise, and undefinedotherwise.
^ >1
cw
< ^3
ccw
^ v6
undefined
1、题意:就是符号V旋转,然后有四种形态分别是V,<,^,>,然后第一行给你四种形态中的两种,求第一种形态是怎么变成第二种形态的,然后第二行给你旋转的次数(每次旋转90°),如果顺时针旋转就输出cw,逆时针旋转就输出ccw,如果是其他情况(顺时针和逆时针都能让第一种形态变成第二种形态也算,我就在这儿错了一次),就输出undefined。
2、思路:一共就十二种情况,直接存数组然后判断了,不过忘记了旋转次数可以是0,在这儿又错了一次。
3、代码:
#include<iostream>using namespace std;struct f{char x;char y;}sp[12];int main(){int n,N,i;char a,b;sp[0].x='v';sp[1].x='v';sp[2].x='v';sp[0].y='<';sp[1].y='^';sp[2].y='>';sp[3].x='<';sp[4].x='<';sp[5].x='<';sp[3].y='^';sp[4].y='>';sp[5].y='v';sp[6].x='^';sp[7].x='^';sp[8].x='^';sp[6].y='>';sp[7].y='v';sp[8].y='<';sp[9].x='>';sp[10].x='>';sp[11].x='>';sp[9].y='v';sp[10].y='<';sp[11].y='^';int cw[12]={1,2,3,1,2,3,1,2,3,1,2,3};int ccw[12]={3,2,1,3,2,1,3,2,1,3,2,1};while(cin>>a>>b){cin>>n;for(i=0;i<12;i++){if(a==sp[i].x&&b==sp[i].y){N=i;break;}}if(n==0){cout<<"undefined"<<endl;continue;}if(n%4==0){cout<<"undefined"<<endl;continue;}if(n%4==cw[N]&&n%4==ccw[N]){cout<<"undefined"<<endl;continue;}if(n%4==cw[N]&&n%4!=ccw[N]){cout<<"cw"<<endl;continue;}if(n%4!=cw[N]&&n%4==ccw[N]){cout<<"ccw"<<endl;continue;}}return 0;}
4、总结:其实我这种方法算是偷懒了吧...
- 16CF1-A
- 16CF1--A
- CF1 A+B+C
- 16CF1-B
- 16CF1--B-1002
- 2017/8/1训练日记(16cf1题解分析)
- Error 160001: Network `cf1' has overlapping subnets
- codeforces 16A - Flag
- 【水】#16 A. Flag
- BC#16 A
- cf 16a Flag
- 16初出茅庐A题
- CodeForces 16A Flag
- CodeForces-16A-Flag
- CodeForces 16A Flag
- 16A.Flag
- Codeforces 16a
- 16-A. Flag
- ThinkPHP5 域名单独路由
- Action/Func/Lamda/匿名委托
- 安卓5.1源码解析 : RecyclerView解析从绘制流程,ViewHolder复用机制,LayoutManger,ItemAnimator等流程全面讲解
- Date类型转换成String类型和String类型转换成Date类型
- 字符串编程题一道
- 16CF1-A
- __attribute__ ((packed)) 的作用
- KMP算法
- 欢迎使用CSDN-markdown编辑器
- Smart210 ping不通tftp服务器
- 萬丈高樓平地
- 机器学习(二十)
- 异 形 卵
- React Native之Flexbox布局