UOJ Goodbye dingyou A

 题链

 注意到 2k^2k+1=1,然后随便做。

#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL anw,op,n,l,r;
int T;
signed main () {
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    scanf("%d",&T);
    while (T--) {
     op=0; 
    scanf("%lld",&n);
    for (LL head=max(n-100,1ll);1;head++) {
      if (head&1) anw=(head+1)%4==0?0:1;
      else anw=((head)%4==0)?head:head^1;
     for (LL j=1;j<min(101ll,head);j++) {
       anw^=j-1;
       if (anw==n) {
           op=1; l=j; r=head; break;
       } }
       if (op) break;
     }
     printf("%lld %lld\n",l,r);
    }
}

 

posted @ 2018-03-31 18:23  泪寒之雪  阅读(172)  评论(0编辑  收藏  举报