题解 P8443 【gcd.】
蛮简单的一道题,确实符合普及组T1送分的特点。
一个很简单的结论:相邻两个数的最大公约数一定为1
所以这题我们就可以分类讨论,如果
于是这题就这么愉快的水过去了
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int t;
signed main()
{
t = read();
while(t --)
{
int l = read(), r = read(), x = read();
if(l / x == r / x) cout << l / x << endl;
else cout << 1 << endl;
}
return 0;
}