I double Cheese Li was spicy cabbage!
P5535 [XR-3] grapevine (This question is a flood problem
In casual working of the conscience to remind us:
You may need to use Theorem - Bertrand - cut Theorem Chebyshev.
So what is Bertrand - Chebyshev Theorem?
I do not know, butOmniscient degree of your mother know on the line:
If the integer n> 3, then there is at least one prime number p, comply with n <p <2n - 2. Another argument is slightly weak: for all integer n is greater than 1, there is a prime number p, comply with n <p <2n.
So what's the use of this theorem?
Because it is a number selected from n k, k + 1 must therefore be greater than 1
It is not just and Bertrand - cut coincides conditions than Chebyshev theorem?
Yes, we think about the two cases:
1. If k + 1 is a prime number, then in two ways:
I.1 ~ n multiples do not contain k + 1, then obviously the first day it
II.1 ~ n containing multiple k + 1, then take a few days?
Two days later, Why? Since the first day, all of the multiple number k + 1 is removed all know, so gcd ((2 * (k + 1)), (2 * (k + 1)) + 1) = 1 is constant. So just two days.
2. If k + 1 is not a prime number:
It is two days, to tell people have k + 1 is prime number, then Bertrand -> 3, in line with the presence of p n <p <2 * n n-Chebyshev Theorem;
Konjac may speak not very clear, bear with me, I could understand how the sensibility.
#include<bits/stdc++.h>
using namespace std;
#define int long long //一定要开long long,不开long long 见祖先
int n, k;
bool prime(int x)//很清晰的质数筛
{
if(x == 1)//特判一下1
return 0;
if(x == 2)//特判一下2
return 1;
for(int i = 2; i <= sqrt(x); ++ i)//就是枚举每个数,看看它是否是它的约数
if(x % i == 0)//如果不是的话
return 0;//直接return false
return 1;
}
signed main()
{
scanf("%lld%lld", &n, &k);
if(prime(k + 1) && 2 * k >= n)//其实,也很好理解,想一想,如果一个数是质数那么是不是除去它的倍数的数都与它互质?所以prime(k + 1)是判断它是不是质数,后面就是找有没有它的倍数(因为是连续的所以只有比一下大小即可
printf("1");
else//除去1的答案就是二了(会有解释
printf("2");
return 0;
}
PS:Please re-read copy