Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41833 | 老方 | 二进制数数 | C++ | Compile Error | 0 MS | 0 KB | 336 | 2024-02-23 13:35:59 |
#include<bits/stdc++.h> using namespace std; int count(char str[],char ch='1'){ int c=0; for(int i=0;i<strlen(str);i++){ if(str[i]==ch){ c++; } } return c; } int main(){ int n,m,cnt=0; cin>>n>>m; for(int i=n;i<=m;i++){ char str[10001]; itoa(i,str,2); cnt+=count(str); } cout<<cnt; return 0; }