zoukankan      html  css  js  c++  java
  • Vijos

    屠龙宝刀点击就送

    模拟不写了。

    提供一些位运算巧妙方法(非原创)。

    #include<cstdio>
    typedef unsigned int u32;
    
    u32 n;
    
    inline void p(u32 x){//Debug
    	for(int i=31;i>=0;i--){
    		if(i%4==3)printf(" ");
    		printf("%u",x&(1<<i)?1:0);
    	}
    	printf("
    ");
    }
    
    int main(){
    //	freopen("swap.in","r",stdin);
    //	freopen("swap.out","w",stdout);
    	scanf("%u",&n);
    	/*
    	p(n);
    	p(n>>16);
    	p((n-((n>>16)<<16)));
    	p((n-((n>>16)<<16))<<16);
    	p((n>>16)+((n-((n>>16)<<16))<<16));
    	*/
    	printf("%u
    ",(n>>16)+((n-((n>>16)<<16))<<16));//我的沙茶做法
        //Notice the order between +- and >><<,add"()"
    	//LevelUp: int a=n/65536,b=n%65536;printf("%d
    ",b*65536+a);
    	//LevelUp++: printf("%u
    ",((n<<16)|(n>>16)));//unsigned int's Natural feature
    }
    

    //不知道为什么longlong位运算总会出锅,但unsignedint放心用

  • 相关阅读:
    2017年3月9日上午学习
    3.17上午
    3.16上午
    3.16下午
    3.15
    2017.3.14
    3.14
    217.3.13上午
    2017.4.7-morning
    2017.4.6-afternoon
  • 原文地址:https://www.cnblogs.com/Y15BeTa/p/11836591.html
Copyright © 2011-2022 走看看