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

题解:分情况来嘛,偶次就不用管了只需要讨论奇次
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=;
const int mod=1e9+;
int main()
{
char a,b;
int n;
scanf("%c %c",&a,&b);
scanf("%d",&n);
if(n%==) printf("undefined\n");
else if(a=='^'&&b=='>'){
if(n%==) printf("cw\n");
else if(n%==) printf("ccw\n");
}
else if(a=='^'&&b=='<'){
if(n%==) printf("ccw\n");
else if(n%==) printf("cw\n");
}
else if(a=='>'&&b=='^'){
if(n%==) printf("ccw\n");
else if(n%==) printf("cw\n");
}
else if(a=='>'&&b=='v'){
if(n%==) printf("cw\n");
else if(n%==) printf("ccw\n");
}
else if(a=='v'&&b=='>'){
if(n%==) printf("ccw\n");
else if(n%==) printf("cw\n");
}
else if(a=='v'&&b=='<'){
if(n%==) printf("cw\n");
else if(n%==) printf("ccw\n");
}
else if(a=='<'&&b=='^'){
if(n%==) printf("cw\n");
else if(n%==) printf("ccw\n");
}
else if(a=='<'&&b=='v'){
if(n%==) printf("ccw\n");
else if(n%==) printf("cw\n");
}
return ;
}
 

Codeforce 834A - The Useless Toy的更多相关文章

  1. 【Codeforces Round #426 (Div. 2) A】The Useless Toy

    [Link]:http://codeforces.com/contest/834/problem/A [Description] [Solution] 开个大小为4的常量字符数组; +n然后余4,-n ...

  2. http://codeforces.com/contest/834

    A. The Useless Toy time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】

    A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  4. Codeforces Round #426 (Div. 2)

    http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...

  5. Codeforces Round #426 (Div. 2) A,B,C

    A. The Useless Toy 题目链接:http://codeforces.com/contest/834/problem/A 思路: 水题 实现代码: #include<bits/st ...

  6. Codeforces834A

    A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  7. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  8. Codeforces Round #426 (Div. 2)A题&&B题&&C题

    A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...

  9. BZOJ 1010: [HNOI2008]玩具装箱toy [DP 斜率优化]

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9812  Solved: 3978[Submit][St ...

随机推荐

  1. 20180328 Redis和MSMQ

    以前接触的页面记录多为session或者传递的方式短暂记忆.今天接触了一个Redis作为缓存的想法,在之前我也是用过Redis ,但是只是作为异步任务系统记录是否执行成功使用,目前看来用Redis也可 ...

  2. Java字符串复制

    Java字符串复制 public boolean topicFilterMatch(String topicFilter, String topic) { if (topicFilter == nul ...

  3. 模仿以太坊 ERC20 规范的 Hyperledger Fabric 实现 Token 通证

    合约: package main /* -------------------------------------------------- Author: netkiller <netkill ...

  4. (转)Fabric CA环境的集成

    PS:因为我部署的是集群(4peer+1order),需要为order,org1,org2分别建立一个CA,拿org1使用举例,获取org1根证书私钥名称:PRIVATE_KEY.sh #!/bin/ ...

  5. Django 框架 数据库操作

    数据库与ORM 1    django默认支持sqlite,mysql, oracle,postgresql数据库.  <1> sqlite django默认使用sqlite的数据库,默认 ...

  6. huawei

    线程堆栈(Thread Stack)和托管堆(Managed Heap) 每个正在运行的程序都对应着一个进程 (process),在一个进程内部,可以有一个或多个线程(thread),每个线程都拥有一 ...

  7. [LeetCode] 100. Same Tree_Easy tag: DFS

    Given two binary trees, write a function to check if they are the same or not. Two binary trees are ...

  8. [LeetCode] 620. Not Boring Movies_Easy tag: SQL

    X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...

  9. 机器学习算法的调试---梯度检验(Gradient Checking)

    梯度检验是一种对求导结果进行数值检验的方法,该方法可以验证求导代码是否正确. 1. 数学原理   考虑我们想要最小化以 θ 为自变量的目标函数 J(θ)(θ 可以为标量和可以为矢量,在 Numpy 的 ...

  10. cocos2d-x JS 富文本(为一段文本中的个别字体上颜色)

    setWinText : function (levelStr1,levelStr2,levelStr3,color1,color2) { var imgRankingBG = this.contai ...