Edge

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4214    Accepted Submission(s): 2600

Problem Description
For
products that are wrapped in small packings it is necessary that the
sheet of paper containing the directions for use is folded until its
size becomes small enough. We assume that a sheet of paper is
rectangular and only folded along lines parallel to its initially
shorter edge. The act of folding along such a line, however, can be
performed in two directions: either the surface on the top of the sheet
is brought together, or the surface on its bottom. In both cases the two
parts of the rectangle that are separated by the folding line are laid
together neatly and we ignore any differences in thickness of the
resulting folded sheet.
After several such folding steps have been
performed we may unfold the sheet again and take a look at its longer
edge holding the sheet so that it appears as a one-dimensional curve,
actually a concatenation of line segments. If we move along this curve
in a fixed direction we can classify every place where the sheet was
folded as either type A meaning a clockwise turn or type V meaning a
counter-clockwise turn. Given such a sequence of classifications,
produce a drawing of the longer edge of the sheet assuming 90 degree
turns at equidistant places.
 
Input
The
input contains several test cases, each on a separate line. Each line
contains a nonempty string of characters A and V describing the longer
edge of the sheet. You may assume that the length of the string is less
than 200. The input file terminates immediately after the last test
case.
 
Output
For
each test case generate a PostScript drawing of the edge with commands
placed on separate lines. Start every drawing at the coordinates (300,
420) with the command "300 420 moveto". The first turn occurs at (310,
420) using the command "310 420 lineto". Continue with clockwise or
counter-clockwise turns according to the input string, using a sequence
of "x y lineto" commands with the appropriate coordinates. The turning
points are separated at a distance of 10 units. Do not forget the end
point of the edge and finish each test case by the commands stroke and
showpage.

You may display such drawings with the gv PostScript interpreter, optionally after a conversion using the ps2ps utility.

 
Sample Input
V
AVV
 
Sample Output
300 420 moveto
310 420 lineto
310 430 lineto
stroke
showpage
300 420 moveto
310 420 lineto
310 410 lineto
320 410 lineto
320 420 lineto
stroke
showpage
 
Source
[题意]:给定起点(300,420)和初始方向→,给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°.求路径经过的点
[分析]:设置方向和坐标
[代码]:

#include<bits/stdc++.h>
using namespace std; int main()
{
char s[];
while(cin>>s){
printf("300 420 moveto\n310 420 lineto\n");
int dir=,x=,y=;//1→ -1← 2↑ -2↓
for(int i=;i<strlen(s);i++)
{
switch(dir)//每次转弯后走10个单位
{
case ://→ V=左转 A=右转
if(s[i]=='V') dir=,y+=;
else dir=-,y-=;
break;
case ://↑
if(s[i]=='V') dir=-,x-=;
else dir=,x+=;
break;
case -:
if(s[i]=='V') dir=-,y-=;
else dir=,y+=;
break;
case -:
if(s[i]=='V') dir=,x+=;
else dir=-,x-=;
break;
}
printf("%d %d lineto\n",x,y);
}
printf("stroke\nshowpage\n");
}
return ;
}

模拟

HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]的更多相关文章

  1. HDU - 1033 Edge 【模拟】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1033 题意 给定一个起始点 300 420 走的第一步是 310 420 下面的每一步 都由 输入决定 ...

  2. HDU 1033 - Edge

    题目很水 然翻译感人 顺时针或者逆时针走,输出坐标 #include <iostream> using namespace std; ]; int p; ]={,,,-,}; ]={,,- ...

  3. HDU 1033

    http://acm.hdu.edu.cn/showproblem.php?pid=1033 这题的题干说的很绕,结合样例不难理解题意,走折线,A代表顺时针,V代表逆时针,给一个包含A和V的字符串,输 ...

  4. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  5. mysql学习1:数据类型:数字型,日期和时间,字符串类型(总结)

    mysql数据类型:数字型,日期和时间,字符串类型 摘要 MySQL中定义数据字段的类型对数据库的优化是非常重要的: MySQL支持多种类型,大致可以分为三类,如下. 数字类型 整数:tinyint. ...

  6. HDU 5442 后缀自动机(从环字符串选定一个位置 , 时针或顺时针走一遍,希望得到字典序最大)

    http://acm.hdu.edu.cn/showproblem.php?pid=5442 题目大意: 给定一个字符串,可理解成环,然后选定一位置,逆时针或顺时针走一遍,希望得到字典序最大,如果同样 ...

  7. Hdu 3294 Girls' research (manacher 最长回文串)

    题目链接: Hdu 3294  Girls' research 题目描述: 给出一串字符串代表暗码,暗码字符是通过明码循环移位得到的,比如给定b,就有b == a,c == b,d == c,.... ...

  8. HDU 1033(坐标移动 模拟)

    题意是说有一点从(300,410)的位置出发,向右移动到(310,410)后开始转向,A 表示向顺时针转,V 表示向逆时针转,每次转向后沿当前方向前进 10 个单位, 输出其坐标,再补充一点格式上的东 ...

  9. POJ 3344 &amp; HDU 2414 Chessboard Dance(模拟)

    题目链接: PKU:http://poj.org/problem? id=3344 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2414 Descrip ...

随机推荐

  1. [Poj1273]Drainage Ditches(网络流)

    Description 给图,求最大流 最大流模板题,这里用dinic Code #include <cstdio> #include <cstring> #include & ...

  2. 【Remove Nth Node From End of List】cpp

    题目: Given a linked list, remove the nth node from the end of list and return its head. For example, ...

  3. C 语言 习题 1-9

    练习1-9 编写一个将输入复制到输出的程序,并将其中连续的多个空格用一个空格代替. #include <stdio.h> int main(int argc, char const *ar ...

  4. seajs引入jquery

    seajs 2.2.1在config文件中preload一次jquery,就可以在整个项目中使用jquery.如下: seajs.on('exec', function(module) { if (m ...

  5. Python+Selenium中级篇之-Python读取配置文件内容

    本文来介绍下Python中如何读取配置文件.任何一个项目,都涉及到了配置文件和管理和读写,Python支持很多配置文件的读写,这里我们就介绍一种配置文件格式的读取数据,叫ini文件.Python中有一 ...

  6. git放弃修改&放弃增加文件

    1. 本地修改了一堆文件(并没有使用git add到暂存区),想放弃修改. 单个文件/文件夹: git checkout -- filename 所有文件/文件夹: git checkout . 2. ...

  7. 【转】tomcat与apache,tomcat与servlet的区别

    tomcat与apache的区别:(转自:http://blog.csdn.net/longzs/article/details/10959945) 1.apache支持静态页,tomcat支持动态的 ...

  8. Web进程被kill掉后线程还在运行怎么办?

    目录 背景描述 原因分析 处理方案 参考 背景描述 系统有一个配置表,系统在启动后会启动一个线程,每隔5分钟将配置表里所有的数据更新到内存中. 系统是通过jenkins构建(直接kill掉Web进程, ...

  9. ansible中playbook使用

    palybook使用 ####yaml语法ansible中使用的yaml基础元素:变量Inventory条件测试迭代 playbook的组成结构InventoryModulesAd Hoc Comma ...

  10. 减法要用 signed 型

    今天调试一个程序,因为Feedback是电流采样值,Setpoint是PWM值,这两个不可能是负值.所以以为Setpoint和Feedback这两个变量都可以设置为u16型(unsigned int) ...