Delta-wave HDU - 1030
Delta-wave
The traveller needs to go from the cell with number M to the cell
with number N. The traveller is able to enter the cell through cell
edges only, he can not travel from cell to cell through vertices. The
number of edges the traveller passes makes the length of the traveller's
route.
Write the program to determine the length of the shortest route connecting cells with numbers N and M.
6 12
Sample Output
3 OJ-ID:
hdu-1030 author:
Caution_X date of submission:
20191010 tags:
规律题 description modelling:
给定图,问两个数字之间的“距离” major steps to solve it:
将给定图分为3个图,两个数字之间的距离就是两个数字分别在3个图中的距离之和 warnings: AC Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,m;
while(~scanf("%lld%lld",&n,&m)) {
ll cn,cm,ln,lm,rn,rm;
cn=ceil(sqrt(n));
cm=ceil(sqrt(m));
lm=(m-(cm-)*(cm-)-)/+;
ln=(n-(cn-)*(cn-)-)/+;
rm=(cm*cm-m)/+;
rn=(cn*cn-n)/+;
ll ans=;
ans=abs(cn-cm)+abs(ln-lm)+abs(rn-rm);
printf("%lld\n",ans);
}
return ;
}
Delta-wave HDU - 1030的更多相关文章
- uva 1478 - Delta Wave(递推+大数+卡特兰数+组合数学)
option=com_onlinejudge&Itemid=8&category=471&page=show_problem&problem=4224" st ...
- HDU3723 Delta Wave —— 卡特兰数
题目链接:https://vjudge.net/problem/HDU-3723 Delta Wave Time Limit: 6000/3000 MS (Java/Others) Memory ...
- HDU 3723 Delta Wave (高精度+calelan数)
题意:给定一个图,问你只能向上向下,或者平着走,有多少种方法可以走到最后一个格. 析:首先先考虑,如果没有平的情况就是calelan数了,现在有平的情况,那么就枚举呗,因为数很大,所以要用高精度. 答 ...
- hdu 1030 Delta-wave (C++, 0ms, explanatory comments.) 分类: hdoj 2015-06-15 12:21 45人阅读 评论(0) 收藏
problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include ...
- hdu 1030 Delta-wave(数学题+找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...
- hdu 1030 Delta-wave
Delta-wave Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- HDU 1030 Delta-wave 数学题解
给出一个数字塔,然后求沿着数字之间的边走,给出两个数字,问其路径最短的长度是多少. 看似一条搜索题目,只是有一定做题经验的人都知道,这个不是搜索题,直接搜索肯定超时. 这个是依据规律计算的数学题目. ...
- HDU 1030(三角数阵 数学)
题意是问在给定的三角形数阵中从一个数到另一个数所要跨过的边数. 最初的时候很迷,除了发现每层的数字个数与层数间的关系和每层数最后一个数与层数的关系外什么也没看出来,打算先求出数字所在的层数,然后计算到 ...
- HDU 1030 数学题
给出两点,求这两点在图上的最短路径 分别以最上,左下,右下为顶点,看这个三角图形 ans=这三种情况下两点的层数差 #include "stdio.h" #include &quo ...
随机推荐
- elementui中的el-table中拼接两个列表字段
我们知道,在ElementUI中我们是使用下面的语法来展示列表字段的: <el-table :data="yanggbs" stripe style="width: ...
- angular 前端路由不生效解决方案
angular 前端路由不生效解决方案 Intro 最近使用 Angular 为我的活动室预约项目开发一个前后端分离的客户端,在部署上遇到了一个问题,前端路由不生效,这里记录一下.本地开发正常,但是部 ...
- 用Java实现二叉查找树
二叉查找树的实现 1. 原理 二叉查找树,又称为二叉排序树.二叉搜索树.对于树中每一个节点X,它的左子树中所有项的值小于X中的项,而它的右子树中所有项的值大于X中的项.二叉查找树的平均深度为O(log ...
- PlayJava Day007
今日所学: /* 2019.08.19开始学习,此为补档. */ 1.String类 实例化:①String name1 = "张三" ; ②String name2 = new ...
- SpringBoot(六) SpringBoot整合Swagger2(自动化生成接口文档)
一:在上篇文章pom增加依赖: <dependency> <groupId>io.springfox</groupId> <artifactId>spr ...
- SQL Server中的LEFT、RIGHT函数
SQL Server中的LEFT.RIGHT函数. LEFT:返回字符串中从左边开始指定个数字符. LEFT(character_expression,integer_expression); RIG ...
- overflow-x:scroll失效问题解决
在移动设备上设置overflow-x:scroll,大部分机型都是展示正常的,在安卓哦5.0系统上,无论怎么样滚动条都不会生效,终于找到了解决办法: display: -webkit-box; // ...
- input监听回车
1.el-input 2.强制监听
- Ubantu搭建虚拟环境
配置虚拟环境 Ubantu16.0.4 1.安装python虚拟环境 sudo apt-get install virtualenv 2.vrtaulenvwrapper是virtualenv的扩展包 ...
- Python—变量详解
变量赋值 a = 1 b = 2 c = 3 print a, b, c # 1 2 3 a = b = c = 1 print a, b, c # 1 1 1 a, b, c = 1, 2, 3 p ...