新注册公司网站建设,三金网手机网站,z怎么做优惠券网站,网站百度百科怎么做P8623 [蓝桥杯 2015 省 B] 移动距离 题目 解析代码 题目 解析
完了完了T.T#xff0c;这个题我做了20分钟
解题思路就是分组#xff0c;但是编写的时候最好把边界值过一遍【题目提供的测试数据肯定是最好通过的数据#xff0c;需要你自己过一遍特殊数据#xff0c;然后再… P8623 [蓝桥杯 2015 省 B] 移动距离 题目 解析代码 题目 解析
完了完了T.T这个题我做了20分钟
解题思路就是分组但是编写的时候最好把边界值过一遍【题目提供的测试数据肯定是最好通过的数据需要你自己过一遍特殊数据然后再测试自己的代码】我就是这样被卡20minsQAQ
代码
#include iostream
#include vector
#include string
#include algorithm
#include math.h
#include queue#include cctype
using namespace std;
int w, m, n;
int h1, l1, h2, l2;
int main() {cin w m n;h1 (m - 1) / w;if (h1 % 2 0)l1 m % w;elsel1 w - (m % w) 1;h2 (n - 1) / w;if (h2 % 2 0)l2 n % w;elsel2 w - n % w 1;cout abs(h2 - h1 ) abs(l2 - l1);return 0;
}