Codeforces Round #426 (Div. 2)-A. The Useless Toy
来源:互联网 发布:js解析url中的参数 编辑:程序博客网 时间:2024/06/05 13:34
题目: A. The Useless Toy time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputWalking 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.
InputThere 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.
OutputOutput cw, if the direction is clockwise,ccw – if counter-clockwise, and undefined otherwise.
ExamplesInput^ >1
Outputcw
Input< ^3
Outputccw
Input^ v6
Outputundefined
题意:判断第一个字符(^,>,v,<)怎么变成第二个字符(^,>,v,<),顺时针输出cw,逆时针输出ccw,不确定输出undefined
思路:找规律,判断旋转90、180、360度...后的状态
CODE:
#include<bits/stdc++.h>using namespace std;int main(){ int n; char ch1,ch2; while(~scanf("%c%*c%c%d%*c",&ch1,&ch2,&n)){ if(ch1=='^'){ if(ch2=='^'||ch2=='v') puts("undefined"); else if(ch2=='>'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else if(ch1=='>'){ if(ch2=='>'||ch2=='<') puts("undefined"); else if(ch2=='v'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else if(ch1=='v'){ if(ch2=='v'||ch2=='^') puts("undefined"); else if(ch2=='<'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else{ if(ch2=='>'||ch2=='<') puts("undefined"); else if(ch2=='^'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } } return 0;}
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 undefined otherwise.
^ >1
cw
< ^3
ccw
^ v6
undefined
题意:判断第一个字符(^,>,v,<)怎么变成第二个字符(^,>,v,<),顺时针输出cw,逆时针输出ccw,不确定输出undefined
思路:找规律,判断旋转90、180、360度...后的状态
CODE:
#include<bits/stdc++.h>using namespace std;int main(){ int n; char ch1,ch2; while(~scanf("%c%*c%c%d%*c",&ch1,&ch2,&n)){ if(ch1=='^'){ if(ch2=='^'||ch2=='v') puts("undefined"); else if(ch2=='>'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else if(ch1=='>'){ if(ch2=='>'||ch2=='<') puts("undefined"); else if(ch2=='v'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else if(ch1=='v'){ if(ch2=='v'||ch2=='^') puts("undefined"); else if(ch2=='<'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } else{ if(ch2=='>'||ch2=='<') puts("undefined"); else if(ch2=='^'){ if(n%4==1) puts("cw"); else puts("ccw"); } else{ if(n%4==1) puts("ccw"); else puts("cw"); } } } return 0;}
- Codeforces Round #426 (Div. 2) A. The Useless Toy
- Codeforces Round #426 (Div. 2)-A. The Useless Toy
- Codeforces Round #426 (Div. 2) A The Useless Toy
- Codeforces Round #426 (Div. 2) A. The Useless Toy
- Codeforces Round #426 (Div. 2) A The Useless Toy
- Codeforces Round #426 (Div. 2) A. The Useless Toy
- Codeforces Round #426 (Div. 2) The Useless Toy
- Codeforces Round #426 (Div. 2) The Useless Toy 数组环
- #426 (Div. 2) A. The Useless Toy
- (模拟)Codeforces Round #426 A. The Useless Toy
- 【CodeForces】426Div2 A The Useless Toy
- Codeforces 834A-The Useless Toy
- Codeforces 834 A The Useless Toy
- CodeForces 834A The Useless Toy
- codeforces 834-A. The Useless Toy
- codeforces 834A The Useless Toy
- 【CodeForces】834A The Useless Toy 水
- Codeforces 843A:The Useless Toy
- 【死磕Java并发】-----J.U.C之阻塞队列:PriorityBlockingQueue
- 贝塞尔曲线
- python+eclipse环境搭建
- java eclipse安装
- SSH框架的项目执行流程
- Codeforces Round #426 (Div. 2)-A. The Useless Toy
- [设计模式]SINGLETON(单件)_对象创建型模式
- Redis学习四(java使用redis)
- LeetCode 541 Reverse String II
- codeforces 384C Milking cows(脑洞+思维)
- 运维技术盘点
- select2 api参数中文文档
- 线程与进程,线程的可用状态、创建、启动、停止、交互
- 在一个div中有两个子元素,子元素浮动,左边div高度随右边变化