Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
55234 | yuboyuan | 数1的个数 | C++ | Accepted | 0 MS | 256 KB | 351 | 2024-11-03 19:48:17 |
#include<iostream> #include<cmath> using namespace std; int main() { int n,s=0; cin>>n; for(int i1=1;i1<=n;i1++) { for(int i2=1;i2<=5;i2++) { int a=i1; a%=(int)pow(10,i2); a/=(int)pow(10,i2-1); if(a==1) s++; } } cout<<s; return 0; }