1 条题解

  • 1
    @ 2026-6-26 19:48:01
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+10;
    const int INF=0x3f3f3f3f;
    int t,n,ans;
    int main(){
        cin>>t;
    	while(t--){
    		cin>>n;
    		ans=0;
    		while(n){
    			if(n%2==1){
    				ans++;
    				n/=2;
    				n+=n%2;
    			}
    			else{
    				n/=2;
    			}
    		}
    		cout<<ans<<endl;
    	}
    	return 0;
    }
    
    
    • 1

    信息

    ID
    3201
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    133
    已通过
    38
    上传者