题目链接:点击打开题目

这个写一串例子就知道规律了。
代码如下:
#include<queue>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a))
#define PI acos(-1.0)
int main()
{
LL n,k;
int Case = 1;
while (~scanf ("%lld %lld",&n,&k))
{
printf ("Case #%d: ",Case++);
if (n == 2)
{
printf ("%lld\n",((k-1)%2)+1);
continue;
}
if (k <= n)
printf ("%lld\n",k);
else
{
k -= n - 1;
LL ant = ((k-1) / (n-1)) + 1;
LL rest = ((k-1) % (n-1)) + 1;
if (rest == 1)
printf ("%lld\n",(ant & 1) ? n : n-1);
else
printf ("%lld\n",rest-1);
}
}
return 0;
}