A. The Useless Toy

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
 //2017-08-18
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const char cw[] = {'^', '>', 'v', '<'};
const char ccw[] = {'^', '<', 'v', '>'}; int main()
{
int n;
char ch1, ch2;
while(cin>>ch1>>ch2){
cin>>n;
n = n%;
bool fg1 = false, fg2 = false;
for(int i = ; i < ; i++){
if(cw[i] == ch1 && cw[(i+n)%] == ch2){
fg1 = true;
}
}
for(int i = ; i < ; i++){
if(ccw[i] == ch1 && ccw[(i+n)%] == ch2){
fg2 = true;
}
}
if(fg1 && !fg2)
cout<<"cw"<<endl;
else if(!fg1 && fg2)
cout<<"ccw"<<endl;
else
cout<<"undefined"<<endl;
} return ;
}

Codeforces834A的更多相关文章

随机推荐

  1. PICE(3):CassandraStreaming - gRPC-CQL Service

    在上一篇博文里我们介绍了通过gRPC实现JDBC数据库的streaming,这篇我们介绍关于cassandra的streaming实现方式.如果我们需要从一个未部署cassandra的节点或终端上读取 ...

  2. underscore.js源码研究(5)

    概述 很早就想研究underscore源码了,虽然underscore.js这个库有些过时了,但是我还是想学习一下库的架构,函数式编程以及常用方法的编写这些方面的内容,又恰好没什么其它要研究的了,所以 ...

  3. python packaging

    python packaging 一.困惑 作为一个 Python 初学者,我在包管理上感到相当疑惑(嗯,是困惑).主要表现在下面几个方面: 这几个包管理工具有什么不同? * distutils * ...

  4. POJ 2656

    #include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("a ...

  5. 课程一(Neural Networks and Deep Learning),第二周(Basics of Neural Network programming)—— 3、Python Basics with numpy (optional)

    Python Basics with numpy (optional)Welcome to your first (Optional) programming exercise of the deep ...

  6. JVM中OutOFMemory和StackOverflowError异常代码

    1.Out of Memory 异常 右键Run As --->Run Configuration 设置JVM参数 -Xms20m -Xmx20m 上代码: /** * VM Args:-Xms ...

  7. WTF小程序之<web-view>

    叨叨两句 昨天爬了一下午坑才出来的我向大家问好

  8. hexo 静态页面生成后页面打不开的问题

    我这里的原因是4000端口被占用了 *** hexo入门指南教程: 官方文档 用Hexo 3 搭建github blog 做一款hexo主题(进阶) 坑 1 要安装node和git 2 别忘了安装he ...

  9. Linux环境下Java中文乱码解决方案

    相信很多朋友遇到过Java的乱码问题,最近我也在解决一个“使用文本生成图片过程中中文以及特殊字符乱码”的问题:花了我大量时间,Debug了sun.font.sun.awt下面的各种源码,终于搞懂了其机 ...

  10. php -- 文件上传下载

    ----- 026-upload.php ----- <!DOCTYPE html> <html> <head> <meta http-equiv=" ...