题目链接:
https://c.aoyacms.com/problem.php?id=1625&codepath=%2Fproblemset.php%3Fzd%3D%25E5%25BE%25AA%25E7%258E%25AF%25E7%25BB%2593%25E6%259E%2584-%25E5%25BE%25AA%25E7%258E%25AF%25E5%25B5%258C%25E5%25A5%2597
#include<iostream>
using namespace std;
int main()
{
int n,sum=1;
int i,j;
cin>>n;
for(i=2; i<=n; i++)
for(j=i; j>0; j/=10)
if(j%10==1) sum++;
cout<<sum<<endl;
return 0;
}