4 solutions

  • 4
    @ 2023-11-20 20:31:27
    #include<bits/stdc++.h>
    using namespace std;
    unsigned int n;
    int main(){
    	cin>>n;
    	unsigned int a=n<<16,b=n>>16;//a为n的低位,b为高位 
    	cout<<(a|b);//等于a+b 
    	return 0;//无需多言 
    }
    

    投机取巧的方法

    • @ 2023-11-21 19:46:11
      #include <bits/stdc++.h>
      using namespace std;
      int main(int argc, char **argv){
      	unsigned int n;
      	cin >> n;
      	unsigned int di = n << 16,gao = n >> 16;
      	cout << di + gao;
      	return 0;
      }
      
    • @ 2024-10-15 18:58:32

      详细注释

      ```cpp
      #include<bits/stdc++.h>
      using namespace std;
      unsigned int n;//自定义 int n
      int main(){
      	cin>>n;//输入
          unsigned int a=n<<16,b=n>>16;//按题目所示,前16位为高位,后16位为高位
          cout<<(a|b);//把交换后的数输出
      	return 0;
      }
      
  • 0
    @ 2024-10-1 15:27:17

    不用换进制的方法,但因为没有读到二进制的数所以过不了

    <可惜~~>

    # include<bits/stdc++.h>
    using namespace std;
    int main(){
    	long long a;
    	int x,y;
    	cin>>a;
    	x=a%65536;//65536是2的16次方
    	y=(a-x)/65536;
    	cout<<y+x*65536;
    	return 0;
    }
    ```
    • 0
      @ 2023-11-11 15:10:44
      using namespace std;
      long powpro(long n,int m){ 
      	int mem=n;
      	if(m==0)return 1;
      	for(int i=1;i<m;i++){
      		n*=mem;
      	}
      	return n;
      }
      int n;
      char tmp;
      char c[32]="";
      long ans=0;
      int main(){
      	cin>>n;
      	for(int i=31;i>=0;i--){
      		if(n>=pow(2,i)){
      			c[31-i]='1';
      			n-=pow(2,i);
      		}
      		else{
      			c[31-i]='0';
      		}
      	}
      	for(int i=31;i>15;i--){
      		tmp=c[i];
      		c[i]=c[i-16];
      		c[i-16]=tmp;
      	}
      	for(int i=31;i>=0;i--){
      		if(c[i]=='1'){
      			ans+=long(powpro(2,31-i));
      		}
      	}
      	cout<<ans;
      	return 0;
      }
      
      • -1
        @ 2024-12-13 20:01:29
        #include<bits/stdc++.h>
        using namespace std;
        
        int main(){
        	long long n,a,b;
        	cin>>n;
        	a=n>>16;
        	b=n<<16;
        	printf("%u",a+b);
        }
        

        每日批判

        • 1

        Information

        ID
        909
        Time
        1000ms
        Memory
        125MiB
        Difficulty
        5
        Tags
        # Submissions
        102
        Accepted
        43
        Uploaded By