16 条题解

  • 2
    @ 2024-12-10 16:36:35
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e3+10;
    const int INF=0x3f3f3f3f;
    unsigned int n,a;
    int main(){
    	cin>>n;
    	a=(n>>16)+(n<<16);
    	cout<<a;
    	
    	return 0;
    }
    小鸟
    
    • 2
      @ 2024-12-10 16:35:16
      #include<bits/stdc++.h>
      using namespace std;
      unsigned int n,a;
      int main(){
      	cin>>n;
      	a=(n>>16)+(n<<16);
      	cout<<a;
      	return 0;
      }
      
      
      • 2
        #include<bits/stdc++.h>
        using namespace std;
        const int N=1e3+10;
        const int INF=0x3f3f3f3f;
        unsigned int n,a;
        int main(){
        	cin>>n;
        	a=(n>>16)+(n<<16);
        	cout<<a;
        	
        	return 0;
        }
        
        • 0
          @ 2023-4-29 15:59:42
          #include<cstdio>
          #include<string>
          #include<bits/stdc++.h>
          #define LL long long
          using namespace std;
          const int INF=0x3f3f3f3f;
          const int N=2e5+10;
          int n,x;
          int main(){
          	unsigned int a;
          	cin>>a;
          	cout<<(a>>16)+(a<<16);
          	return 0;
          }
          
          
          • -1
            @ 2022-4-30 10:17:45

            ···#include<iostream> #include<stdio.h> #include<math.h> #include<iomanip> #include<string.h> #include<algorithm> #define LL long long using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int main(){ long long a,b; cin>>a; LL c=a>>16; b=a-(c<<16); LL x=(b<<16)+c; cout<<x; }

            • -1
              @ 2021-11-23 22:57:14

              1.int型最多存储31位整形[即正负数都有,范围在-2312^{31} 2312^{31}-1],而unsigned int也是31位,但是存储的是正整数[范围是11 2322^{32}-1]。

              2.C++运算中,若出现溢出,则 自动取模 。举个例子:在unsigned int型当中,计算2322^{32}+400时,实际的运算是(2322^{32}+400)%2322^{32},结果就是400.

              综合以上几点,能不能发现什么呢?

              问题让我们求的其实是2进制下交换前后16位,不就是向左移16位(根据上文2.),加上右移16位吗?

              代码如下

              #include<iostream>
              #include<cstdio>
              #include<cmath>
              #include<cstdlib>
              #include<cstring>
              #include<algorithm>
              using namespace std;
              int main(){
                  unsigned int n;
                  cin>>n;
                  cout<< (n<<16)+(n>>16);
                  return 0;
              }
              
              • -1
                @ 2021-11-6 23:30:39
                #include<iostream>
                #include<cmath>
                using namespace std;
                string t00(int num){
                	string s = "";
                	while(num){
                		s += char(num%2+'0');
                		num /= 2;
                	}
                	for(int i = 0; i < s.size() / 2; i++){
                		swap(s[i],s[s.size()-i-1]);
                	}
                	if(s.size() < 32){
                		while(s.size() != 32){
                			s = '0' + s;
                		}
                	}
                	return s;
                }
                string sw(string s){
                	for(int i = 0; i < 16; i++){
                		swap(s[i],s[i+16]);
                	}
                	return s;
                }
                long long t01(string s){
                	long long ans = 0;
                	for(int i = 31; i >= 0; i--){
                		ans += (long long)((s[i]-'0') * pow(2,31-i));
                	}
                	return ans;
                }
                void run(){
                	int n;
                	cin >> n;
                	cout << t01(sw(t00(n)));
                }
                int main(){
                	run();
                }
                
                • -2
                  @ 2023-11-29 20:03:43
                  #include<bits/stdc++.h>
                  const int N=1e5+10;
                  const int INF=0x3f3f3f3f;
                  unsigned int n,a;
                  using namespace std;
                  int main(){
                  	cin>>n;
                  	a=(n>>16)+(n<<16);
                  	cout<<a;
                  	return 0;
                  }
                  
                  • -2
                    @ 2023-11-26 19:59:14
                    #include<iostream>
                    #include<cstring>
                    using namespace std;
                    unsigned int n,sum; 
                    int main(){
                    	cin>>n;
                    	sum=(n>>16)+(n<<16);
                    	cout<<sum;
                    } 
                    
                    
                    • -2
                      @ 2023-11-25 19:33:20

                      #include<bits/stdc++.h> using namespace std; int main() { //int x,s,n //低位转换 //高位转换 //输出 unsigned x,s,n; cin>>n; s=(n<<16); x=(n>>16); cout<<s+x<<endl; }

                      • -2
                        @ 2023-11-25 19:31:57

                        #include<bits/stdc++.h> using namespace std; int main() { //int x,s,n //低位转换 //高位转换 //输出 unsigned x,s,n; cin>>n; s=(n<<16); x=(n>>16); cout<<s+x<<endl; }

                        • -2
                          @ 2023-11-25 19:31:41

                          #include<bits/stdc++.h> using namespace std; int main() { //int x,s,n //低位转换 //高位转换 //输出 unsigned x,s,n; cin>>n; s=(n<<16); x=(n>>16); cout<<s+x<<endl; }

                          • -2
                            @ 2023-11-25 19:31:38

                            #include<bits/stdc++.h> using namespace std; int main() { unsigned n; int a,x; cin>>n; cout<<(n>>16)+(n<<16)<<endl; return 0; }

                            • -2
                              @ 2023-5-30 16:38:03
                              using namespace std;
                              unsigned n;
                              int main(){
                              	cin >> n;
                              	cout << (n >> 16)+(n << 16);
                              	return 0;
                              }//超简单的,不需要太多
                              
                              • -2
                                @ 2022-4-30 10:25:02
                                #include <queue>
                                #include <math.h>
                                #include <stack>
                                #include <stdio.h>
                                #include <iostream>
                                #include <vector>
                                #include <iomanip>
                                #include <string.h>
                                #include <algorithm>
                                using namespace std;
                                #define LL long long
                                const int N = 1e5 + 10;
                                const int INF = 0x3f3f3f3f;
                                int main()
                                {
                                //  unsigned int a,b;
                                //   cin >> a;
                                //  unsigned int c=a>>16;
                                //  b=a-(c<<16);
                                //  unsigned int x=(b<<16)+c;
                                //  cout << x <<endl;
                                    unsigned int a;
                                    cin >> a;
                                	cout << (a << 16)+(a >> 16);
                                }
                                
                                • -2
                                  @ 2022-1-8 20:58:46
                                  #include <math.h>
                                  #include <stdio.h>
                                  #include <iostream>
                                  #include <string.h>
                                  #include <algorithm>
                                  using namespace std;
                                  int main()
                                  {
                                      long long  n ;
                                      cin >> n;
                                      long long h = n >> 16;
                                      n = n - (h << 16);
                                      long long sum = (n << 16) + h;
                                      cout << sum << endl;
                                      return 0;
                                  }
                                  
                                  • 1

                                  信息

                                  ID
                                  1219
                                  时间
                                  1000ms
                                  内存
                                  128MiB
                                  难度
                                  4
                                  标签
                                  递交数
                                  513
                                  已通过
                                  237
                                  上传者