Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
24301 | 老方 | 数1的个数 | C++ | Accepted | 0 MS | 244 KB | 227 | 2023-08-10 13:00:06 |
#include<bits/stdc++.h> using namespace std; int main() { int R,sum=0; cin>>R; for(int i=1;i<=R;i++) { int j=i; while(j) { if(j%10==1){ sum+=1; } j/=10; } } cout<<sum; return 0; }