题解 P6476 【[NOI Online #2 提高组]涂色游戏】
这里是民间数据的 std:
不妨设
则会发现:最坏情况,也就是从
这样就有
因为可能不互质,所以可以两边除
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
inline int gcd(int a,int b)
{
return !b?a:gcd(b,a%b);
}
int main()
{
//freopen("color.in","r",stdin);
//freopen("color.out","w",stdout);
int T=read();
while (T--)
{
int p1=read(),p2=read(),k=read();
if (k==1)
{
puts("NO");
continue;
}
if (p1>p2)
swap(p1,p2);
int GCD=gcd(p1,p2);
p1/=GCD;
p2/=GCD;
puts((p2>2 && (p2-2)/p1+1>=k)?"NO":"YES");
}
//fclose(stdin);
//fclose(stdout);
return 0;
}