1 条题解

  • 0
    @ 2023-12-25 11:39:33
    #include <iostream>
    
    using namespace std;
    
    int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);	
    	int n;
    	while(cin >> n){
    	int p=0;
    	if(n==0){
    		cout << "0" << '\n';
    		continue;
    	}
    	for(int i=31;i>=0;i--){
    		if((n>>i&1)){           //去除无效的0 
    			p=1;
    		}
    		if(p==1){
    		cout << (n>>i&1);       //&运算输出 1&1=1 0&1=0 
    	}
    	}
    		cout << '\n';
    }
    	return 0;
    }
    
    • 1

    信息

    ID
    195
    时间
    3000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    564
    已通过
    195
    上传者