Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41761 | lmz120809 | 1的个数 | C++ | Accepted | 0 MS | 256 KB | 204 | 2024-02-23 10:18:45 |
#include<iostream> using namespace std; int main() { int n,cnt=1; cin>>n; for(int i=10;i<=n;i++){ int m=i; while(m){ if(m%10==1) cnt++; m/=10; } } cout<<cnt; return 0; }