A. The Useless Toy

原创 2017年09月11日 20:34:56

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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

Output cw, if the direction is clockwise, ccw – if counter-clockwise, and undefined otherwise.

Examples
input
^ >
1
output
cw
input
< ^
3
output
ccw
input
^ v
6
output
undefined


解题说明:此题是一道模拟题,按照题目意思求出旋转顺序,注意需要对一个周期4求余数。


// codeforece.cpp: 定义控制台应用程序的入口点。
//

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main()
{

	char c1, c2;
	int t, timec, timecc, ci, cci, i;
	scanf("%c%*c", &c1);
	scanf("%c%*c", &c2);
	scanf("%d", &t);
	char c[4] = { 'v' ,'<' ,'^' ,'>' };
	char cc[4] = { 'v' ,'>' ,'^' ,'<' };
	for (i = 0; i < 4; i++)
	{
		if (c1 == c[i])
		{
			ci = i;
		}
		if (c1 == cc[i])
		{
			cci = i;
		}
	}
	timec = (ci + t % 4) % 4;
	timecc = (cci + t % 4) % 4;
	if (c[timec] == cc[timecc])
	{
		printf("undefined\n");
	}
	else if (c[timec] == c2)
	{
		printf("cw\n");
	}
	else if (cc[timecc] == c2)
	{
		printf("ccw\n");
	}
	return 0;
}


版权声明:

相关文章推荐

Codeforces Round #426 (Div. 2)-A. The Useless Toy

题目:                        ...

Codeforces - 834A. The Useless Toy - 模拟

A. The Useless Toy 题目链接 分类:模拟、map应用 1.题意概述 给你两个字符和旋转次数,问从第一个字符到第二个字符是通过顺时针还是逆时针旋转还是两种方向都行? 2....

CF834A-The Useless Toy

A. The Useless Toytime limit per test1 second memory limit per test256 megabytes inputstandard inp...

UVa Problem 10065 Useless Tile Packers (没用的瓷砖打包公司)

// Useless Tile Packers (没用的瓷砖打包公司) // PC/UVa IDs: 111405/10065, Popularity: C, Success rate: averag...

useless as only one part

  • 2011-07-05 14:47
  • 19.07MB
  • 下载

Volatile: Almost Useless for Multi-Threaded Programming

Volatile: Almost Useless for Multi-Threaded Programming Submitted by Arch D. Robison......

UVA 10065 Useless Tile Packers

水题,求个面积,再求个凸包的面积,减一下除以凸包面积即可。 复制的时候 多复制了个空格,PE了次。。以为是换行问题,改了下WA了。。。后来才看到。。。看来复制输出也要小心啊。。 #include #i...

Connect without Context is Useless

  • 2013-02-26 17:01
  • 3.53MB
  • 下载

MEail same useless files

  • 2009-08-24 11:01
  • 990KB
  • 下载

BZOJ-1010 [HNOI2008]玩具装箱toy

解题思路: 斜率优化DP 这道题= =嘛算是斜率优化的入门题目了。还是非常经典的感觉。 首先考虑,这道题目有经验的小伙子一眼就可以想出来状态转移方程是什么。 显然是 dp[i] = min(d...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)