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

题目:
                                                 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


题意:判断第一个字符(^,>,v,<)怎么变成第二个字符(^,>,v,<),顺时针输出cw,逆时针输出ccw,不确定输出undefined

思路:找规律,判断旋转90、180、360度...后的状态

CODE:

#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n;
        char ch1,ch2;
        while(~scanf("%c%*c%c%d%*c",&ch1,&ch2,&n)){
                if(ch1=='^'){
                        if(ch2=='^'||ch2=='v') puts("undefined");
                        else if(ch2=='>'){
                                if(n%4==1) puts("cw");
                                else puts("ccw");
                        }
                        else{
                                if(n%4==1) puts("ccw");
                                else puts("cw");
                        }
                }
                else if(ch1=='>'){
                        if(ch2=='>'||ch2=='<') puts("undefined");
                        else if(ch2=='v'){
                                if(n%4==1) puts("cw");
                                else puts("ccw");
                        }
                        else{
                                if(n%4==1) puts("ccw");
                                else puts("cw");
                        }
                }
                else if(ch1=='v'){
                        if(ch2=='v'||ch2=='^') puts("undefined");
                        else if(ch2=='<'){
                                if(n%4==1) puts("cw");
                                else puts("ccw");
                        }
                        else{
                                if(n%4==1) puts("ccw");
                                else puts("cw");
                        }
                }
                else{
                        if(ch2=='>'||ch2=='<') puts("undefined");
                        else if(ch2=='^'){
                                if(n%4==1) puts("cw");
                                else puts("ccw");
                        }
                        else{
                                if(n%4==1) puts("ccw");
                                else puts("cw");
                        }
                }
        }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cities are most interesting when they combine the new with the old, and the traditional with the avant-garde. New York juxtaposes high rises with church spires, crammed spaces with green vistas, streets of shops with streets of houses, glass-and-steel towers with cast-iron buildings, or houses of brick and timber. The older buildings of our cities give us the possibility of visualizing the past, for they are, in a true sense, time capsules. The capitol building of Virginia, in Richmond, brings Robert E. Lee to life, Louis XIV is best understood amid the carefully calculated grandeur of Versailles, and the remnants of the Parthenon give voice to Demosthenes. So, too, in New York City, the Brooklyn Bridge and the Empire State Building signify aspects of the vibrant history of our great metropolis. In the buildings, parks, and historic areas that survive in New York City and are recorded in this book, we see many facets of the city’s architecture, its history, and its culture. The original Pennsylvania Station may be gone, as are the Bartholdi Hotel, the Athenaeum Club building, and the old Metropolitan Opera House; but the structures and sites that remain, and are protected as landmarks, are testament to New York’s rich heritage. Daily living was as varied in the past three centuries as it is for us in the initial years of the twenty-first century. And our schools, churches, and commercial structures testify today to this diversity, reminding us where we have been, and how far we have come, in a few hundred years. We see the untouchable past along with the un-built beginning, and new spires rising alongside the old. Historic preservation is more than the desire for permanence expressed through architecture; it is an embodiment of the relationship between urbanism and populace. One of the motivations for writing this book was to further enhance the level of awareness of the places we inhabit, and to encourage even more citizens to become involved in helping to revitalize their communities—and not simply for aesthetic reasons. Landmarks preservation, I believe, improves the wellbeing of our citizens, not just by means of the “result”—the restored and rescued buildings and sites—but also through the process of involving large numbers of people and nurturing a growing constituency for civic concern and pride. It has not been, and will not be, the New York City Landmarks Preservation Commission alone, but the individuals and grassroots organizations that give voice and vitality to the movement that has transformed our city—aesthetically, culturally, and economically. Another reason for writing this book is to attempt to correct some misconceptions regarding landmark preservation, in particular the notion that a building is “frozen” once it receives landmark status. Hardly! In fact, as we accumulated data, our greatest problem was keeping track of all the changes that had taken place in a landmark since designation and determining the use of the landmark. Effecting changes in landmark structures is not only wholly possible, but has been constant and widespread. Because of repairs, renovations, and adaptation to landmarks, even their appearances can change, which proves that a landmark is not static and museum-like, but, as is true of almost any building in active use, constantly evolving. Far from seeking simply to preserve a bygone world, the members of the New York City Landmarks Preservation Commission accept the circumstances of a changing world and attempt to preserve the past without jeopardizing the future. No generation has the right to make the city a monotonous monument to a single moment. But while giving progress and change their due, we must not permit the best of our past to be buried or otherwise lost. This book attempts to provide a brief indication of the history and significance of each of the designated properties in New York City, through June 2011. The text has been based in part on the designation reports of the New York City Landmarks Preservation Commission. Initially, my assistants and I systematically gathered and catalogued each report. Next we communicated, orally or in writing, with owners, city officials, historical societies, architects, preservationists, and citizens, requesting historical and anecdotal material. Then began the elaborate process of documenting the designated landmarks: cross-checking and authenticating the historical information, architectural descriptions, photographs, and fresh anecdotal material that we had gathered about each of them The exhaustive research involved interviews, conversations, and digging in archives so that each building or site would be presented with its own story, its own intricate history. Exhaustive and repeated efforts to verify the accuracy of the material were made. This was not possible in every instance because of the inability to locate verifiable sources. Therefore, it is our hope that if you have, or are aware of, verifiable data or emendations that relate to any of these landmarks, you will share them with us. We hope to continue our researches and incorporate appropriate changes in future digital editions of this book. In an attempt to document New York’s architectural history, the landmarks in this book have been organized chronologically by date of construction. In several instances, to accommodate all of the materials, this order is not strictly followed. This book reveals how the hopeful vision of a few has become a strong instrument for the protection of our architectural future, in recognition of our rich past. It represents our achievements in the structures that have been created and endured, and which continue to shape our City. Preservationists have long understood the benefits of protecting the past from destruction. The architecture of New York City should be saved so that future generations can envision the past and experience the magic of stepping back in time. Preservation of our landmarks provides a sense of continuity between past and present, and an appreciation of the accomplishments that outlast the individual life. Every civilization is formed not merely by its own achievements, but by what it has inherited from the past. We are reminded that the values and aspirations these landmarks embody possess continuing relevance today, and make us aware of the past’s importance to the future.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值