题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=1033

题意

给定一个起始点 300 420

走的第一步是 310 420

下面的每一步 都由 输入决定

如果输入 V 那么就往左边走10个单位长度

比如 样例一 给的V 走到上面了

因为它本来的方向是 右边 那么 对于它的左边 其实就是上边

如果输入A 就往右边走10个单位长度

思路

可以定义方向

up 0 right 1 down 2 left 3

然后 给定V 就是 dis– 给A 就是 dis++

但是要注意 如果dis <0 dis 应该为3

dis 如果>=4 应该 模3

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a, b) memset(a, (b), sizeof(a))
#define pb push_back using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss; const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-8; const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const int MOD = 1e9 + 7; int Move[4][2]
{
0, 10, // up
10, 0, // right
0,-10, // down
-10, 0, // left
}; int main()
{
string s;
while (cin >> s)
{
int len = s.size();
printf("300 420 moveto\n");
printf("310 420 lineto\n");
// up 0 right 1 down 2 left 3
int x = 310, y = 420, dir = 1;
for (int i = 0; i < len; i++)
{
if (s[i] == 'V')
dir--;
else
dir++;
if (dir < 0)
dir = 3;
dir %= 4;
x += Move[dir][0];
y += Move[dir][1];
printf("%d %d lineto\n", x, y);
}
printf("stroke\n");
printf("showpage\n");
}
}

HDU - 1033 Edge 【模拟】的更多相关文章

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

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

  2. HDU 1033 - Edge

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

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

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

  4. HDU 1033

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

  5. HDU 4121 Xiangqi 模拟题

    Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...

  6. hdu 5071 Chat(模拟)

    题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...

  7. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

  8. HDU 2568[前进]模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2568 关键思想:傻傻地模拟 代码如下: #include<iostream> using ...

  9. hdu 4964 恶心模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...

随机推荐

  1. ddmrp

    DDMRP 特点 在供应链加入 mts 缓冲,解耦 lead time, 缩小 bullwhip 效应,最小化库存 buffer动态调整 buffer 分3个颜色共 4个区域[zone],为 gree ...

  2. iOS仿支付宝首页的刷新布局效果

    代码地址如下:http://www.demodashi.com/demo/12753.html XYAlipayRefreshDemo 运行效果 动画效果分析 1.UI需要变动,向上滑动的时候,顶部部 ...

  3. Mysql视图的创建及使用

    视图理解: 视图又叫虚表.同真实的表一样,视图包含一系列带有名称的列和行数据.但是,视图并不在数据库中以存储的数据值集形式存在.行和列数据来自由定义视图的查询所引用的表,并且在引用视图时动态生成. 视 ...

  4. java中poi解析excel(兼容07版本以上及以下:.xls和.xlsx格式)

    package com.genersoft.cbms.ysbz.ExcelDr.cmd; import com.genersoft.cbms.ysbz.ExcelDr.dao.ExcelDrDao; ...

  5. 工作总结 用, 隔开数据 后台不可以用 List<string> 接收 get请求直接通过浏览器发请求传数组或者list到后台

    旁边的 css js 为项目的 加载 css js 地址 只加载引用的样式 js http://localhost:8736/LinInFoKPI/ExcelPrint?line=&start ...

  6. css 温故而知新 select-option 文字方向居右

    对select-option使用text-align:right;是无效的. 正确的姿势是:direction: ltr; 另外值得一提的是,通常还需要配合一点padding来美化.

  7. 我的_vimrc文件

    """"""""""""""""&quo ...

  8. explicit 和 implicit 的用法

    explicit 和 implicit 属于转换运算符,如用这两者可以让我们自定义的类型支持相互交换 explicti 表示显式转换,如从 A -> B 必须进行强制类型转换(B = (B)A) ...

  9. [转载]Axure RP 7.0下载地址及安装说明

    Axure RP是产品经理必备的原型制作工具,因为很多同学是新手,在这里整理一下axure7.0的下载.安装和汉化流程,希望能够帮到大家. Axure RP是美国Axure Software Solu ...

  10. ffmpeg截图

    ffmpeg.exe -probesize 32768 -i "rtmp://localhost/live/1 live=1" -y -t 0.001 -ss 1 -f image ...