답안 #7038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7038 2014-07-13T00:36:52 Z gs13068 CATS (NOI14_cats) C++
0 / 25
0 ms 1080 KB
#include<cstdio>

int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	int tcn;
	scanf("%d",&tcn);
	while(tcn--)
	{
		long long K,P;
		long long T,X,L,N;
		scanf("%lld%lld%lld",&X,&L,&N);
		X--;
		N<<=1;
		T=(L+N-1)/N;
		K=T-1;
		if(K>62)K=62;
        if(T*N==L)
		{
            P=X%6;
            X=(X/6)&((1LL<<K)-1);
            for(T=0;X;X>>=1)T^=X&1;
            if(T)
			{
				if(P==1||P==3)printf("%lld\n",((L+N-1)/N+1)*N);
				else if(P==2||P==4)printf("%lld\n",((L+N-1)/N+1)*N+1);
				else printf("%lld\n",L/N*N+1);
			}
			else
			{
				if(P==0||P==4)printf("%lld\n",((L+N-1)/N+1)*N);
				else if(P==1||P==5)printf("%lld\n",((L+N-1)/N+1)*N+1);
				else printf("%lld\n",L/N*N+1);
			}
		}
		else
		{
            P=X%4;
            X=(X/4)&((1LL<<K)-1);
            for(T=0;X;X>>=1)T^=X&1;
            if(T)
			{
				if(P==0||P==3)printf("%lld\n",(L+N-1)/N*N+1);
				else printf("%lld\n",(L+N-1)/N*N);
			}
			else
			{
				if(P==1||P==2)printf("%lld\n",(L+N-1)/N*N+1);
				else printf("%lld\n",(L+N-1)/N*N);
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -