题意:问你A-B 互相 取或   互相 取与  分别值是多少

解题思路:看那些位数不变,那些位数变化

解题代码:

 1 // File Name: b.cpp
 2 // Author: darkdream
 3 // Created Time: 2015年04月04日 星期六 12时22分58秒
 4 
 5 #include<vector>
 6 #include<list>
 7 #include<map>
 8 #include<set>
 9 #include<deque>
10 #include<stack>
11 #include<bitset>
12 #include<algorithm>
13 #include<functional>
14 #include<numeric>
15 #include<utility>
16 #include<sstream>
17 #include<iostream>
18 #include<iomanip>
19 #include<cstdio>
20 #include<cmath>
21 #include<cstdlib>
22 #include<cstring>
23 #include<ctime>
24 #define LL long long
25 
26 using namespace std;
27 int t;
28 LL L , R;
29 int main(){
30      scanf("%d",&t);
31      for(int CA = 1; CA <= t;CA++)
32      {
33         scanf("%lld %lld",&L,&R); 
34         LL ans1,ans2; 
35         ans1 = ans2 = 0  ;
36         LL i ; 
37         for(i = 63 ;i >= 0 ;i --)
38         {
39            LL ta = (L >> i) &1;
40            LL tb = (R >> i) &1;
41            if(ta == tb)
42            {
43               ans1 += ta << i ; 
44               ans2 += ta << i ; 
45            }else
46            {
47                break;
48            }
49         }
50         for(LL j = i ;j >= 0;j --)
51         {
52             ans1 += 1ll << j ;     
53         }
54         printf("Case %d: %lld %lld\n",CA,ans1,ans2);
55      }
56 return 0;
57 }
View Code

 

posted on 2015-04-05 20:54  dark_dream  阅读(118)  评论(0编辑  收藏  举报