HDU 1030(三角数阵 数学)】的更多相关文章

题意是问在给定的三角形数阵中从一个数到另一个数所要跨过的边数. 最初的时候很迷,除了发现每层的数字个数与层数间的关系和每层数最后一个数与层数的关系外什么也没看出来,打算先求出数字所在的层数,然后计算到该层最后一个数要跨过的边数,由于各层最后一个数之间所跨过的边数与层数差有关(称层数距离), 因此可以求得一条路线:如图 但两数间的最短路线依然求不到,感觉也不能用到每层最后一个数所跨边数作差,而层数距离也不一定会体现在最短路径中,比如 7 和 13 这一组,就只跨一条边即可. 借鉴了别人的博客,才知…
Delta-wave HDU - 1030 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 e…
给出一个数字塔,然后求沿着数字之间的边走,给出两个数字,问其路径最短的长度是多少. 看似一条搜索题目,只是有一定做题经验的人都知道,这个不是搜索题,直接搜索肯定超时. 这个是依据规律计算的数学题目. 我这里的思路是一层一层往下搜,利用层间的规律加速,实现层跃,到了同一层,或者同一个对角列的时候就能够直接计算出结果了.对角列即顺着三角形的边能直接走到目标的列. 数学计算出层与层之间相差2,而也能够利用这个规律计算N和M所在的层和列. 这样做由点麻烦,只是我自己琢磨出来的,不错的思路.O(∩_∩)O…
problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include <cmath> #include <algorithm> int calPathLength(int x, int y) { //path length from 1 (1st line, lower) to a number in ith line is only differ by…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7163    Accepted Submission(s): 2772 Problem Description A triangle field is numbe…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathys…
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map o…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意简单,直接用容斥原理即可 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include &…
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 Description There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of b…
意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号的差值的绝对值. 算法: 题目就是要求                  watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MTg0NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissol…