Delta-wave
Delta-wave
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4602 Accepted Submission(s): 1745

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.
#include<stdlib.h>
#include<math.h>
int main()
{
int n,m,h_n,h_m,ll_n,rl_n,rl_m,ll_m,r;
while(~scanf("%d%d",&n,&m))
{
if(sqrt(n)>(int)sqrt(n))
h_n = (int)sqrt(n)+1;
else
h_n = (int)sqrt(n);
rl_n = (h_n*h_n-n)/2+1;
ll_n = (n-((h_n-1)*(h_n-1)+1))/2+1;
if(sqrt(m)>(int)sqrt(m))
h_m = (int)sqrt(m)+1;
else
h_m = (int)sqrt(m);
rl_m = (h_m*h_m-m)/2+1;
ll_m = (m-((h_m-1)*(h_m-1)+1))/2+1;
r = abs(h_n-h_m)+abs(ll_n-ll_m)+abs(rl_n-rl_m);
printf("%d\n",r);
}
return 0;
}
Delta-wave的更多相关文章
- 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数了,现在有平的情况,那么就枚举呗,因为数很大,所以要用高精度. 答 ...
- RIFF和WAVE音频文件格式
RIFF file format RIFF全称为资源互换文件格式(Resources Interchange File Format),是Windows下大部分多媒体文件遵循的一种文件结构.RIFF文 ...
- IEEE 802.11p (WAVE,Wireless Access in the Vehicular Environment)
IEEE 802.11p(又称WAVE,Wireless Access in the Vehicular Environment)是一个由IEEE 802.11标准扩充的通讯协定.这个通讯协定主要用在 ...
- Wave - 花たん 音乐
Wave 歌手:花たん 所属专辑:Flower 間違えて宇宙終わって(宇宙因为一个错误而终结了) 青信号はいつも通り(通行的灯号一如往常的) 飛んでまた止まって(又再停止传播) また 飛びそうだ(然后 ...
- Dirac Delta Function
也称为Degenerate pdf, 退化概率密度函数. 未经考证的解释是: 当正态分布的\(\sigma \to 0\)时, 正态分布就退化为这个分布了. 定义 \[ \delta(x) = \be ...
- Web 播放声音(AMR 、WAVE)
最近甚是苦闷,属于边学边做,跳进了很多坑,别提有多惨了,不过结果还是不错滴,纵观前后,一句话足以概括 “痛并快乐着” ~~~ ok,我少说废话,下面来总结下 Web 播放声音一些注意事项. 说到 We ...
- 数据源增量处理(Delta Proess)三大属性:Recod Mode、Delta Type、Serialization
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- 对冲的艺术——delta中性交易
delta中性交易 delta中性交易——外行话 delta中性交易就是构造一个含有期权头寸的组合,使其不受标的股票或指数价格小幅变动的影响.换句话讲,无论标的价格是涨还是跌,组合的市值始终保持不变. ...
随机推荐
- cocoa pods
# cocoa pods * `CocoaPods` 是 iOS 最常用最有名的类库管理工具 * 作为 iOS 程序员,掌握 `CocoaPods` 的使用是必不可少的基本技能 ## pod 命令汇总 ...
- P1417 烹调方案
P1417 烹调方案 题目提供者tinylic 标签 动态规划 难度 普及+/提高 题目背景 由于你的帮助,火星只遭受了最小的损失.但gw懒得重建家园了,就造了一艘飞船飞向遥远的earth星.不过飞船 ...
- MateSublg
MateSublg 说明 使用MetaWeblog的方式提交文章,并自动上传图片. 本插件的官方地址:MateSublg – Sollyu博客 本插件的开源地址:sollyu / MetaSubolg ...
- LAMP 环境 快速安装
(一)安装Apache 1.下载安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 yum install zlib-devel -y wget http://m ...
- Php之Http请求urlencode/rawurlencode
在http请求中,如果参数值带中文最好使用urlencode/rawurlencode函数. 如果参数值中带加号也最好使用,否则后台接收时,+号变成空格,引起不必要的麻烦. 注:urlencode和r ...
- EF初始化mysql数据库codefirst
EF使用Code First修改生成数据库表名的方法 1. 重写OnModelCreating,去掉表名复数 System.Data.Entity.ModelConfiguration.Convent ...
- 将数据库二进制图片导出显示到EPPlus Excel2007中
1.EPPlus Excel 控件可以参考我的另一篇博客:http://blog.163.com/pei_huiping/blog/static/206573067201281810549984/ 这 ...
- HTML5格式化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- C语言结构体中的函数指针
这篇文章简单的叙述一下函数指针在结构体中的应用,为后面的一系列文章打下基础 本文地址:http://www.cnblogs.com/archimedes/p/function-pointer-in ...
- C++库编译
C++库编译 1. POCO编译 进入源文件目录,选择相应的VS版本进行编译(build_vs140). 设置系统环境变量: POCO_BASE 2. Boost编译 ####简单编译 在 ...