HDU1030 Delta-wave
来源:互联网 发布:上古世纪捏脸数据图片 编辑:程序博客网 时间:2024/05/21 09:23
A triangle field is numbered with successive integers in the way shown on the picture below.
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.
Input
Input contains two integer numbers M and N in the range from 1 to 1000000000 separated with space(s).
Output
Output should contain the length of the shortest route.
Sample Input
6 12
Sample Output
3
理解链接:http://blog.csdn.net/moonspiritacm/article/details/53969418
我还没懂~~
#include<stdio.h>#include<math.h>#include<algorithm>#include<iostream>using namespace std;int main(){ long long int m,n; while(~scanf("%lld%lld",&n,&m)) { int a1,a2,b1,b2,c1,c2; a1=sqrt(n-1)+1; a2=sqrt(m-1)+1; b1=(a1*a1-n)/2+1; b2=(a2*a2-m)/2+1; c1=(n-(a1-1)*(a1-1)+1)/2; c2=(m-(a2-1)*(a2-1)+1)/2; printf("%d\n",abs(a1-a2)+abs(c1-c2)+abs(b1-b2)); } return 0;}
- hdu1030-Delta-wave
- hdu1030 - Delta-wave
- HDU1030 Delta-wave
- hdu1030——Delta-wave
- HDU1030 Delta-wave(java)
- HDU1030 Delta-wave(找规律)
- HDU1030 - Delta-wave (找规律)
- ACM-简单题之Delta-wave——hdu1030
- hdu1030 - Delta-wave (三角洲数学水题)
- Delta-wave
- Delta-wave
- Delta-wave
- Delta-wave
- Delta-wave
- Delta-wave
- Delta-wave
- HDU3723 Delta Wave
- HDU 1030 Delta-wave
- 聊一聊为什么要做公众号
- 算法设计与应用基础-第三周
- 设计模式学习笔记—23个模式
- 九度OJ-1480:最大上升子序列和
- @RequestMapping 用法详解之地址映射(转)
- HDU1030 Delta-wave
- 欢迎使用CSDN-markdown编辑器
- 在spring官网上下载spring的jar包及API文档
- 模拟电视信号的数字化
- 设计模式--建造者模式(C++实现)
- jQuery之has()/find()/filter()
- BZOJ 4517: [Sdoi2016]排列计数
- 第一篇
- Android命名规范(重点讲解:包名)