HDU 1030 Delta-wave
来源:互联网 发布:万网域名隐藏whois 编辑:程序博客网 时间:2024/06/10 05:23
题意:求给出的两个数字所在表中的位置的距离。
以前想了好久,都没有想到好的方法,今天在DISCUSS里看到了比较好的解体方法,就把这题做了。
求点到顶部的距离X(层数),到左边的距离Y(层数),到右边的距离Z(层数)。当然也可以求到底边的距离,这样比较麻烦。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>using namespace std;struct node{ int x,y,z;};node oor(int k){ int x = sqrt(k-1.0); int y = (k-x*x-1)/2; int z = ((x+1)*(x+1)-k)/2; node t;t.x=x,t.y=y,t.z=z; return t;}int main(){ freopen("in.txt","r",stdin); int a,b; while(~scanf("%d%d",&a,&b)) { node t=oor(a),e=oor(b); printf("%d\n",abs(t.x-e.x)+abs(t.y-e.y)+abs(t.z-e.z)); } return 0;}
- HDU 1030 Delta-wave
- HDU 1030 Delta-wave
- HDU 1030 Delta-wave
- HDU-1030-Delta-wave
- hdu 1030 Delta-wave
- hdu 1030 Delta-wave
- hdu 1030 Delta-Wave+
- HDU 1030 Delta-wave
- Hdu 1030 Delta Wave
- hdu 1030 Delta-wave
- Delta-wave(HDU 1030)
- hdu 1030 Delta-wave
- hdu 1030 Delta-wave
- HDU 1030 Delta-wave
- hdu 1030 Delta-wave
- 【HDU】 1030 Delta-wave
- hdu 1030 Delta-wave
- hdu 1030 Delta-wave
- U-Boot的常用命令详解
- android 页面停几秒后跳转
- 栈---十进制转化为任意制
- POJ 2993 Emag eht htiw Em Pleh解题报告
- java synchronized 使用方法详解
- HDU 1030 Delta-wave
- ios gb2312转utf-8
- hdu 1215 七夕节
- hdu 2090 算菜价
- js 取DropDownList选中的值
- kingdee bos开发特殊数据权限配置
- uboot 的内存命令使用: mw (修改) md (显示),u-boot 内存 memory
- 本地x86可以, 放到arm上就不行的几种可避免的情况
- w3m: ubuntu下用命令行浏览网页