1 条题解
-
0
gcd
答案是不超过 的,可以通过使用一对 次和一对 次,一定可以达到点 的。总费用为 。
需要检查是否有可能以 的代价到达。由于花费是 ,我们需要找到一对 ,即 , ,并且可以通过持续应用这一对到达单元格 。这意味着存在一个整数 使得 ,即 是 和 的因子。
为了使 , 越大越好, 所以 取 和 的最大公约数
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; #define x first #define y second const int N = 2e5 + 10, mod = 1e9 + 7; void solve() { LL a, b,k; cin >> a >> b >> k; LL g = gcd(a, b); a /= g, b /= g; if(max(a, b) <= k) cout << 1 << endl; else cout << 2 << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; cin >> t; while(t --) solve(); }
- 1
信息
- ID
- 509
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 5
- 已通过
- 1
- 上传者