洛谷—— P3908 异或之和

https://www.luogu.org/problemnew/show/P3908

题目描述

1 \bigoplus 2 \bigoplus\cdots\bigoplus N12N 的值。

A \bigoplus BAB 即AA , BB 按位异或。

输入输出格式

输入格式:

 

1 个整数NN。

 

输出格式:

 

1 个整数,表示所求的值。

 

输入输出样例

输入样例#1: 复制
3
输出样例#1: 复制
0

说明

• 对于50% 的数据,1 \le N \le 10^61N106;

• 对于100% 的数据,1 \le N \le 10^{18}1N1018。

 

打表找规律

 1 #include <cstdio>
 2 
 3 #define LL long long
 4 
 5 inline void read(LL &x)
 6 {
 7     x=0; register char ch=getchar();
 8     for(; ch>'9'||ch<'0'; ) ch=getchar();
 9     for(; ch>='0'&&ch<='9'; ch=getchar()) x=x*10+ch-'0';
10 }
11 
12 int Presist()
13 {
14 //    freopen("out.txt","w",stdout);
15     LL n; read(n);
16     if(n%4==0) printf("%lld\n",n);
17     else if(n%4==1) puts("1");
18     else if(n%4==2) printf("%lld\n",n+1);
19     else if(n%4==3) puts("0");
20     return 0;
21 }
22 
23 int Aptal=Presist();
24 int main(int argc,char**argv){;}

 

posted @ 2017-11-29 20:33  Aptal丶  阅读(232)  评论(0编辑  收藏  举报