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. adb offline解决办法

    假如你连接手机之后,adb devices找不到设备,或者找到了设备,但是device ID后总是offline的状态,那估计就是驱动有问题. 强烈建议1.安装豌豆荚,它可以自己主动修复手机驱动,一般 ...

  2. python 二(续)——面向对象编程进阶

    1.类的成员 2.类成员修饰符 3.类的特殊成员 在python第二课——面向对象初级,文章中介绍了面向对象基本知识: 面向对象是一种编程方式,此编程方式的实现是基于对 类 和 对象 的使用 类 是一 ...

  3. oracle常用关键字和函数

    数据库的增删改查: 增:insert into ... values(); 例:insert into p_emp values(sq_emp.nextval,,sysdate,,null,,); c ...

  4. 【数据结构与算法】Fibonacci Sequence

    学计算机的对 Fibonacci 都并不陌生,在课堂上一讲到递归几乎都会提到 Fibonacci 数列.不久前,我对 Fibonacci 产生了一些兴趣,就在这里把自己的想法给记录下来. 递推公式: ...

  5. Leetcode 542.01矩阵

    01矩阵 给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离. 两个相邻元素间的距离为 1 . 示例 1: 输入: 0 0 0 0 1 0 0 0 0 输出: 0 0 0 0 1 0 ...

  6. PAT——乙级1026and1046

    1026 程序运行时间 (15 point(s)) 要获得一个 C 语言程序的运行时间,常用的方法是调用头文件 time.h,其中提供了 clock() 函数,可以捕捉从程序开始运行到 clock() ...

  7. 目前问题:plupload上传带参数到后台

    目前问题:plupload上传带参数到后台,迟迟没有解决!!! 昨晚到23点多终于完成了! 直接上代码! var uploader = new plupload.Uploader({ //实例化一个p ...

  8. php 不重新编译增加openssl扩展

    安装openssl和开发包 yum install openssl openssl-devel 跳转到PHP源码下的openssl cd /usr/local/src/php-5.5.27/ext/o ...

  9. POJ 3254:Corn Fields(状态压缩DP)

    题目大意:一个矩形的草地,分为多个格子,有的格子可以有奶牛(标为1),有的格子不可以放置奶牛(标为0),计算摆放奶牛的方案数. 分析: f[i,j]表示第i行状态为j的方案总数. 状态转移方程f[i, ...

  10. [BZOJ1280][POJ1149]Emmy卖猪pigs

    [BZOJ1280][POJ1149]Emmy卖猪pigs 试题描述 Emmy在一个养猪场工作.这个养猪场有 \(M\) 个锁着的猪圈,但Emmy并没有钥匙.顾客会到养猪场来买猪,一个接着一个.每一位 ...