P8443 gcd.
P8443 gcd.
题目
因为不知道干什么所以就写了这个题解(
思路
初看:我超,数论,我爬了
再看:入门,应该还能抢救一下
分两种情况考虑:
1. \left\lfloor \frac{l}{x} \right\rfloor=\left\lfloor \frac{r}{x} \right\rfloor
此时
所以
2. \left\lfloor \frac{l}{x} \right\rfloor<\left\lfloor \frac{r}{x} \right\rfloor
由于
而
所以
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL t;
LL l, r, x;
int main() {
cin >> t;
for (int i = 0; i < t; i++) {
cin >> l >> r >> x;
if (r / x > l / x) {
cout << 1 << endl;
}
else {
cout << l / x << endl;
}
}
return 0;
}