Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
45080 YOYOLEE-李昕颖 二进制数数 C++ 通过 0 MS 248 KB 416 2024-04-09 19:23:15

Tests(1/1):


#include<bits/stdc++.h> using namespace std; int a[40],cnt,c; void f(int n){ memset(a,0,cnt); cnt=0; stack<int> st; while(n){ st.push(n%2); n/=2; } while(st.empty()==0){ a[cnt++]=st.top(); st.pop(); } return ; } int main(){ int l,r; cin>>l>>r; for(int i=l;i<=r;i++){ f(i); for(int j=0;j<cnt;j++){ if(a[j]==1) c++; } } cout<<c; return 0; }


测评信息: