Edge

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

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
 

简单的模拟既可以过掉....15ms吧!,选择了switch(),耗掉了些时间,个人是这么觉得的...

代码:

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define maxn 205
char str[maxn];
int main()
{
int len,i,x,y;
char dir; //记录 up,down,left,right
while(scanf("%s",str)!=EOF)
{
len=strlen(str);
if(len==)
return ;
printf("300 420 moveto\n310 420 lineto\n");
x=,y=;
dir='r'; //初始化为向右
for(i=;i<len;i++)
{ if(str[i]=='A')
{
/*顺时针方向进行*/
switch(dir)
{
case 'u': x+=,dir='r'; break;
case 'd': x-=,dir='l'; break;
case 'r': y-=,dir='d'; break;
case 'l': y+=,dir='u'; break;
}
}
else if(str[i]=='V')
{
/*逆时针方向*/
switch(dir)
{
case 'u': x-=,dir='l';break;
case 'd': x+=,dir='r';break;
case 'r': y+=,dir='u';break;
case 'l': y-=,dir='d';break;
}
}
printf("%d %d lineto\n",x,y);
}
printf("stroke\nshowpage\n");
}
return ;
}

hduoj----(1033)Edge的更多相关文章

  1. 【HDOJ】1033 Edge

    题目英文太多,简单翻译了一下:1. For products that are wrapped in small packings it is necessary that the sheet of ...

  2. HDU - 1033 Edge 【模拟】

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

  3. HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]

    Edge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. HDU 1033 - Edge

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

  5. NOI前的考试日志

    4.14 网络流专项测试 先看T1,不会,看T2,仙人掌???wtf??弃疗.看T3,貌似最可做了,然后开始刚,刚了30min无果,打了50分暴力,然后接着去看T1,把序列差分了一下,推了会式子,发现 ...

  6. 杭电acm 1033题

    Problem Description For products that are wrapped in small packings it is necessary that the sheet o ...

  7. What's new in Windows 10 Enterprise with Microsoft Edge.(Windows 10 新功能)

    What's new in Windows 10 Enterprise with Microsoft Edge --带有Edge浏览器的Windows 10 企业版的新功能 本文摘录自公司群发邮件, ...

  8. 如何在Microsoft Edge浏览器中添加一个Hello World插件

    注:本文提到的代码示例下载地址> How to add a Hello World extension to Microsoft Edge Microsoft Edge 随着Win 10一起推出 ...

  9. 取消ie浏览器edge浏览器输入框右边的叉和眼睛

    在ie高版本浏览器和edge浏览器里type为text和password的input框在输入时右边会出现×和眼睛,如果需要清除,方法如下: 首先在页面头部声明兼容性模式 <meta http-e ...

  10. 如何创建一个Edge 浏览器扩展

    随着微软Windows 10 年度更新的发布,数次延宕的Edge 扩展功能终于得到了官方正式支持.我在我的另外一个博客上发布了如何创建一个Edge 浏览器扩展的博文,链接如下: https://blo ...

随机推荐

  1. 2012年及之后的ImageNet比赛的冠军、亚军和季军ImageNet winners after 2012

    2012 0.15 - Supervision (AlexNet) - ~ 60954656 params 0.26 - ISI (ensemble of features) 0.27 - LEAR ...

  2. C++ cout 格式化输出方法

    C语言里可以用printf(),%f来实现浮点数的格式化输出,用cout呢...? iomanip是I/O流控制头文件,就像printf的格式化输出一样. 以下是一些常用的: dec 置基数为10 相 ...

  3. VMware vCenter中, 如何辩认虚机上Raw Device Mapping过了的一块物理磁盘?

    比如说, 我们有一套VMware的环境, 其中有一台运行者ESXi的主机, 其上有十块SAS盘. 这十块盘中的五块盘被RDM到一台虚机上了. 假设你发现有添加多了一块盘, 你想移除掉, 但是5块盘其中 ...

  4. WF4.0(2)----设计工作流

    自从做了程序员,发现自己长胖了,而且自己的身体抵抗力也出了问题,最近身体不适,公司工作任务最近也很赶,上次写了WF4.0的简介,这次就工作中工作流设计的几种方式稍微总结一下.设计工作流包括四种方式:流 ...

  5. 20 个具有惊艳效果的 jQuery 图像缩放插件

    jQuery相对与Flash的魔力已经贯穿整个网络.尽管,Flash层被认为是用于网页设计的首选,然而随着jQuery的出现,以及他的酷似Flash的交互式特效使得网页更加的优雅——Flash开始靠边 ...

  6. Visual Studio 调试方法

    1:命令窗口 CTRL + D + I,可以在立即窗口中写一些临时的代码 2:编辑并继续 选中下面的选项,可以让你在调试暂停中,修改代码,而不用重新启动, 3:执行 单步执行:F10 跳进方法:F11 ...

  7. 【RPC】Thrift ICE 等 RPC 框架相关资料

    RPC框架-Thrift-ICE Apache Thrift - Documentation Apache Thrift - Index of tutorial/ Apache Thrift - Ab ...

  8. IDA远程调试so库JNI_Onload函数

    JNI_OnLoad函数大概功能就是在程序加载so的时候,会执行JNI_OnLoad函数,做一系列的准备工作.很多时候,程序猿们会将一些重要信息放在此函数中,而不是通过某种事件来重复触发.包括说将反调 ...

  9. nodejs pm2的简单应用

    一.简介 pm2是一个带有负载均衡功能的应用进程管理器,类似有Supervisor,forever,详细参数见官网:http://pm2.keymetrics.io 二.安装 Linux Binari ...

  10. Cognos第三方用户认证(CustomJavaProvider)

    关于Cognos第三方用户认证(CustomJavaProvider)的demo网上的例子很多,当然最权威的你可以从Cognos安装的SDK中去探索,本文不详细的说明代码,主要说一下认证的处理过程,以 ...