解题说明:此题是一道模拟题,直接算出 n/3 +1 即 n 中满足这种序列需要多少个1 ,然后跟k 比较,比 k 大就直接 2*k,比 k 小就是 n-k.
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
long long int n, k;
scanf("%lld%lld", &n, &k);
if (k < n && k)
{
printf("1 ");
}
else
{
printf("0 ");
}
if ((3 * k) <= n)
{
printf("%lld\n", k << 1);
}
else
{
printf("%lld\n", n - k);
}
return 0;
}