Description
题目地址: Codeforces
Solution
对于一个询问q,如果q是奇数,那么答案就是(q-1)/2
否则将不断q=q/2+n即可
Code
#include <cstdio>
long long n,x;
int q;
int main(){
scanf("%I64d%I64d",&n,&q);
while(q--){
scanf("%I64d",&x);
while(!(x&1)) x=(x>>1)+n;
printf("%I64d\n",(x+1)>>1);
}
return 0;
}