1的次数,唯一超简题解!

潘璇  •  2个月前


include <bits/stdc++.h>

using namespace std;

int main() {

int n,count=0;
cin>>n;
for(int i=1; i<=n; i++)
{
    int temp=i;
    while(temp!=0)
    {
        if(temp%10==1) count++;
        temp/=10;
    }
}
cout<<count<<endl;
return 0;

}


评论:

OK的~


阿蒟啊~  •  2个月前