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. 小程序升级实时音视频录制及播放能力,开放 Wi-Fi、NFC(HCE) 等硬件连接功能

    “ 小程序升级实时音视频录制及播放能力,开放 Wi-Fi.NFC(HCE) 等硬件连接功能.同时提供按需加载.自定义组件和更多访问层级等新特性,增强了第三方平台的能力,以满足日趋丰富的业务需求.” 0 ...

  2. 显示日历的指令:cal

    1.显示日历的指令:cal (1)参数: (2)实例:

  3. 静态库lib和动态库dll相关总结

    1.静态链接库LIB和动态链接库DLL的区别 若采用静态链接库,lib 中的指令都全部被直接包含在最终生成的 EXE 文件中了.而动态动态链接库则不必被包含在最终 EXE 文件中,EXE 文件执行时可 ...

  4. C 表達式及返回值

    以下程序的输出结果是__A____. #include<stdio.h> main() { ,j=; printf("%d,%d\n",++i,j--); } A., ...

  5. linux下automake用法

    linux下automake用法 2017年02月06日 09:21:14 阅读数:3684 标签: makemakefilegnulinux   作为Linux下的程序开发人员,大家一定都遇到过Ma ...

  6. (转)ThreadLocal-面试必问深度解析

    ThreadLocal是什么 ThreadLocal是一个本地线程副本变量工具类.主要用于将私有线程和该线程存放的副本对象做一个映射,各个线程之间的变量互不干扰,在高并发场景下,可以实现无状态的调用, ...

  7. Python第三弹--------文件和异常

    文件读取: pi_digits.txt 3.1415926535 8979323846    2643383279 file_reader.py with open('pi_digits.txt') ...

  8. 查看Nginx、PHP、Apache和MySQL的编译参数

    1.查看Nginx编译参数 [root@portal finance]# your_nginx_dir/sbin/nginx -V nginx version: nginx/ built by (Re ...

  9. ELK(上)

    什么是ELK: ELK是三个开源软件的缩写,分别表示:Elasticsearch , Logstash, Kibana , 它们都是开源软件.新增了一个FileBeat,它是一个轻量级的日志收集处理工 ...

  10. Tensorflow实现手写体分类(含dropout)

    一.手写体分类 1. 数据集 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data im ...