| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 41708 | jiabokai | 1的个数 | C++ | Accepted | 1 MS | 252 KB | 278 | 2024-02-23 09:33:49 |
#include<bits/stdc++.h> using namespace std; int judge(int m){ int cnt=0; while(m){ if(m%10==1){ cnt++; } m/=10; } return cnt; } int main(){ int n; cin>>n; int cnt=0; for(int i=1;i<=n;i++){ cnt+=judge(i); } cout<<cnt<<endl; return 0; }