Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
45079 YOYOLEE-李昕颖 二进制数数 C++ 编译错误 0 MS 0 KB 418 2024-04-09 19:22:30

Tests(0/0):


#include<bits/stdc++.h> using namespace std; int a[40],cnt,c; void f(int n){ memset(a,a+cnt,0); 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; }


测评信息: