Red Huang

Red Huang

uva 11615

題目意思太坑了,一開始完全看不懂意思

結果竟然是水題

/\*  
 \* GCA : "Computer is artificial subject absolutely,Math is God"  
 \*/  
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <cmath>  
#include <climits>  
#include <vector>  
#include <set>  
#include <map>  
#include <queue>  
#include <cctype>  
#include <utility>  
#include <ctime>  
using namespace std;  
#ifdef DEBUG  
#define VAR(a,b) \_\_typeof(b) a=(b)  
#define debug(...) printf("DEBUG: "),printf(\_\_VA\_ARGS\_\_)  
#else  
#define VAR(a,b) \_\_typeof(b) a=(b)  
#define debug(...)  
#endif  
typedef unsigned int uint;  
typedef long long int Int;  
typedef unsigned long long int UInt;  
#define Set(a,s) memset(a,s,sizeof(a))  
#define Pln() printf("\\n")  
#define For(i,x)for(int i=0;i<x;i++)  
#define CON(x,y) x##y  
#define M 31  
#define PB push\_back  
#define oo INT\_MAX  
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)  
#define eps 1e-9  
#define X first  
#define Y second  
inline bool xdy(double x,double y){return x>y+eps;}  
inline bool xddy(double x,double y){return x>y-eps;}  
inline bool xcy(double x,double y){return x<y-eps;}  
inline bool xcdy(double x,double y){return x<y+eps;}  
const Int mod=1000000007;  
int n,x,y;  
int findheight(int x){  
    for(int i=n-1;i>=0;i--){  
        if((x>>i)&1)return i;  
    }  
    return -1;  
}  
int main() {  
    ios\_base::sync\_with\_stdio(0);  
    int test;  
    scanf("%d",&test);  
    while(test--){  
        scanf("%d%d%d",&n,&x,&y);  
        int hx=findheight(x);  
        int hy=findheight(y);  
        int h=max(hx,hy);  
        int same=(1<<(n-h))-1;  
        printf("%d\\n",((1<<n)-1)-same+1);  
    }  
  
  
  
  
  
  
  
  
  
  
  
  
  
}  
  

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。