链接
题解
金爷太强大了,他今天上橙了
这题就是考虑每个空位从哪里转移过来
若
x
x
x为奇数,
a
n
s
(
x
)
=
x
/
2
+
1
ans(x)=x/2+1
ans(x)=x/2+1
若
x
x
x为偶数,
a
n
s
(
x
)
=
a
n
s
(
x
+
n
−
x
/
2
)
ans(x)=ans(x+n-x/2)
ans(x)=ans(x+n−x/2)
代码
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(_,__) for(_=1;_<=(__);_++)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll read(ll x=0)
{
ll c, f(1);
for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f;
for(;isdigit(c);c=getchar())x=x*10+c-0x30;
return f*x;
}
ll n, q;
ll f(ll pos)
{
if(pos&1)return pos/2+1;
else return f(pos+n-pos/2);
}
int main()
{
n=read(), q=read();
while(q--)
{
printf("%lld\n",f(read()));
}
return 0;
}