1 条题解
-
0
分别求出横、纵坐标的移动次数 ,由于青蛙是横纵交替跳跃的,所以总次数是较大移动次数的两倍,即 .
再考虑跳跃的先后顺序:青蛙先跳 轴,所以若x轴移动的更多,最终会少跳一步,将结果减 即可。
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; #define x first #define y second const int N = 2e5 + 10, M = 60; void solve() { int x, y, k; cin >> x >> y >> k; int t1 = (x + k - 1) / k, t2 = (y + k - 1) / k; if(t1 > t2) cout << t1 * 2 - 1 << endl; else cout << t2 * 2 << endl; } int main() { int t = 1; cin >> t; while(t --) solve(); }
- 1
信息
- ID
- 145
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 18
- 已通过
- 5
- 上传者