AtCoder - 2282 (思维+构造)
题意
https://vjudge.net/problem/AtCoder-2282
告诉你sx,sy,tx,ty,问从s走到t,再从t走到s,再从s走到t,再从t回到s的最短路,每次只能上下左右选一个走1,除了s和t,其他点只能走一次。
思路
这是个沙雕构造题,我画出来了却没看出来。。太沙雕了。
借用别人的图:
然后乱走即可。。
代码
#include <bits/stdc++.h> using namespace std;
#define ll long long
const int N=1e3+5;
const int mod=1e9+7;
int main()
{
ios::sync_with_stdio(false);
int sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;
cout<<"D";
for(int i=0; i<tx-sx+1; i++)
cout<<"R";
for(int i=0; i<ty-sy+1; i++)
cout<<"U";
for(int i=0; i<tx-sx+1; i++)
cout<<"L";
for(int i=0; i<ty-sy; i++)
cout<<"D";
for(int i=0; i<tx-sx; i++)
cout<<"R";
for(int i=0; i<ty-sy+1; i++)
cout<<"U";
for(int i=0; i<tx-sx+1; i++)
cout<<"L";
for(int i=0; i<ty-sy+1; i++)
cout<<"D";
cout<<"R"<<endl;
return 0;
}
//1 2 4 8 16 30 60 96
AtCoder - 2282 (思维+构造)的更多相关文章
- hdu4671 思维构造
pid=4671">http://acm.hdu.edu.cn/showproblem.php? pid=4671 Problem Description Makomuno has N ...
- 思维/构造 HDOJ 5353 Average
题目传送门 /* 思维/构造:赛后补的,当时觉得3题可以交差了,没想到这题也是可以做的.一看到这题就想到了UVA_11300(求最小交换数) 这题是简化版,只要判断行不行和行的方案就可以了,做法是枚举 ...
- Atcoder C - +/- Rectangle(思维+构造)
题目链接:http://agc016.contest.atcoder.jp/tasks/agc016_c 题解:挺简单的构造,很容易想到的构造方法就是(h*w)的小矩阵里其他值赋值为1,最后一个赋值为 ...
- Pythagorean Triples毕达哥斯拉三角(数学思维+构造)
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...
- A Mist of Florescence CodeForces - 989C(思维构造)
题意: 让你构造一个图,使得A,B,C,D的个数为给定的个数,上下左右连通的算一个. 哎呀 看看代码就懂了..emm..很好懂的 #include <bits/stdc++.h> usin ...
- Educational Codeforces Round 53C(二分,思维|构造)
#include<bits/stdc++.h>using namespace std;const int N=1e6+6;int x[N],y[N];int sx,sy,n;char s[ ...
- E - Addition and Subtraction Hard AtCoder - 2273 思维观察题
http://arc066.contest.atcoder.jp/tasks/arc066_c?lang=en 这类题目是我最怕的,没有什么算法,但是却很难想, 这题的题解是这样的,观察到,在+号里面 ...
- 牛客多校训练第八场C.CDMA(思维+构造)
题目传送门 题意: 输入整数m( m∈2k ∣ k=1,2,⋯,10),构造一个由1和-1组成的m×m矩阵,要求对于任意两个不同的行的内积为0. 题解: Code: #include<bits/ ...
- ACM-ICPC 2018 青岛赛区现场赛 D. Magic Multiplication && ZOJ 4061 (思维+构造)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4061 题意:定义一个长度为 n 的序列 a1,a2,..,an ...
随机推荐
- iOS常用算法之两个有序数组合并, 要求时间复杂度为0(n)
思路: 常规思路: 先将一个数组作为合并后的数组, 然后遍历第二个数组的每项元素, 一一对比, 直到找到合适的, 就插入进去; 简单思路: 设置数组C, 对比A和B数组的首项元素, 找到最小的, 就放 ...
- Docker-核心笔记(含Dockerfile,Compose)
Docker-核心笔记(含Dockerfile,Compose) 2017/03 Chenxin 参考 https://yeasy.gitbooks.io/docker_practice Docker ...
- python中基本数据类型以及运算符
python中基本数据类型以及运算符的知识 一.与用户的交互以及python2与python的区别 1.1什么是与用户交互 用户交互就是人往计算机中input(输入数据),计算机print(输出结果) ...
- Linux内核源码分析--内核启动之zImage自解压过程【转】
转自:https://www.cnblogs.com/pengdonglin137/p/3838245.html 阅读目录(Content) zImage来历 piggy.gz压缩文件的特点 vmli ...
- Cisco pppoe上网设置
1.配置虚拟端口: interface Dialer1 ip address negotiated ip nat outside ip virtual-reassembly in encapsulat ...
- 201871010109-胡欢欢《面向对象程序设计(java)》第十六周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...
- 发送post请求的接口
一.简介 所有系统或者软件.网站都是从登录开始,所以首先介绍的第一个post请求是登录. 二.help函数 学习一个新的模块捷径,直接用help()函数查看相关注释和案例内容 for example: ...
- promise 和 setTimeout 在任务队列的执行顺序
setTimeout(() => { console.log() }); const a = new Promise((resolve,reject)=>{ console.log(); ...
- Flask/Tornado/Django
深入学习Python ,用Django做Web后端开发现在Python的用途愈来愈广,服务器.Web.游戏.爬虫.数据分析 以及人工智能 学习之路还很长 技术之路 不能回头 陷进去 就出不来 就跟恋 ...
- Matlab2019a启动慢,寻找许可证耽误时间解决办法
Matlab2017b启动慢,一直处于初始化状态的解决办法 - 善水的博客 - CSDN博客 评论区给出了更为具体的做法,效果非常好. "D:\Program Files\MATLAB\R2 ...