题解:P15266 「UTOI 1A」sp! dusttale
首先不难注意到,一个长度为
所以,答案不是
:::success[Ac Code]
#include <bits/stdc++.h>
using namespace std;
#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc _getchar_nolock
#define pc _putchar_nolock
#endif
#define int long long
#define rint register int
#define R register
#define _ read<int>()
template<class T>inline T read()
{
R T r=0,f=1;R char c=gc();
while(!isdigit(c))
{
if(c=='-') f=-1;
c=gc();
}
while(isdigit(c)) r=(r<<1)+(r<<3)+(c^48),c=gc();
return f*r;
}
inline void out(rint x)
{
if(x<0) pc('-'),x=-x;
if(x<10) pc(x+'0');
else out(x/10),pc(x%10+'0');
}
signed main()
{
rint t=_;
while(t--)
{
rint n=_,m=_;
if(((n-2)>>1)<m||n<=2) puts("-1");
else
{
out(n+1);pc('\n');
}
}
return 0;
}//我也要写吗
:::