关闭

A. The Useless Toy

170人阅读 评论(0) 收藏 举报
分类:

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;
}


0
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

The Useless Toy(水题 暴力枚举)

题意: 你两个字符和旋转次数,问第一个字符是顺时针旋转还是逆时针旋转还是两个方向旋转都可以变成第二个字符 解题思路:用的麻烦法,把所有情况都列举出来!很笨。。。  垃圾代码: #include using namespace std; int main() { char ch...
  • sinat_37668729
  • sinat_37668729
  • 2017-08-01 18:52
  • 132

针对toy datasets的不同聚类方法比较

Comparing different clustering algorithms on toy datasets 针对toy datasets的不同聚类方法比较 原地址 http://scikit-learn.org/stable/auto_examples/cluster/plot_...
  • u010157382
  • u010157382
  • 2015-05-26 13:56
  • 755

【水推理】#72 A. Toy Army

这已经不能bei'c #include using namespace std; // http://codeforces.com/contest/84 // Toy Army int main() { int n; cin>>n; cout<<n/2*3...
  • okcd00
  • okcd00
  • 2014-10-27 15:24
  • 558

实例浅议linux设备驱动程序的编写

我是2012年2月份在亚马逊买了《Linux设备驱动程序》一书,期间断断续续的读了好几次,前几章都读烂了,最后终于在去年完整的读完了一遍,期间的感受就是难,主要难在对于一个初学者,不是那么容易去实践,可能也是由于linux kernel更新的太快了的缘故,有些差异还是很大的,另外书中的例子对于初学者...
  • happytomyoung
  • happytomyoung
  • 2014-02-08 15:32
  • 2833

NOIP2016Day1T1玩具谜题解题报告

原题见洛谷(https://www.luogu.org/problem/show?pid=1563) 这道题是一道很裸的模拟题,在noip的day1t1理论上是最简单的一道题,而且数据范围在100000,基本上纯暴力直接就过了而且1s/128MB的空间限制也不是小了,题目中虽然玩具有左右,寻找的方...
  • a1351937368
  • a1351937368
  • 2017-07-26 22:51
  • 1061

POJ 2318 TOYS 计算几何(点与直线关系)

TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10668   Accepted: 5130 Description Calculate t...
  • u013557725
  • u013557725
  • 2014-10-15 22:01
  • 719

[BZOJ1010][HNOI2008]玩具装箱toy 斜率优化第一题

很明显我们得到朴素的转移方程dp[i]=min{dp[j]+(i−j−1+sum[i]−sum[j]−L)2,dp[i]}  (0≤j<i)dp[i]=min\{dp[j]+(i-j-1+sum[i]-sum[j]-L)^2,dp[i]\}~~(0\le j<i) ...
  • slongle_amazing
  • slongle_amazing
  • 2015-12-16 17:13
  • 1689

ScaleAnimation 缩放动画效果

ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)  参数说明: ...
  • songlang90
  • songlang90
  • 2015-08-05 20:12
  • 248

自己的一个toy

准备写个toy: 实现这么几个功能: 从 新浪,凤凰网,搜狐等抓取当天的新闻(目前暂定一天抓三次)。 对他们进行分词,然后看看他们关注的话题的不同。                     &...
  • hellonlp
  • hellonlp
  • 2013-04-06 21:41
  • 1253

A. 2Char (暴力)

Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters....
  • h1021456873
  • h1021456873
  • 2015-11-05 10:52
  • 333
    个人资料
    • 访问:2080325次
    • 积分:37060
    • 等级:
    • 排名:第132名
    • 原创:1496篇
    • 转载:121篇
    • 译文:19篇
    • 评论:955条
    最新评论