Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
27798 吴乐涵 数1的个数 C++ Accepted 100 0 MS 252 KB 199 2021-12-18 15:11:39

Tests(2/2):


#include<bits/stdc++.h> using namespace std; int n,ans,t; int main(){ cin>>n; for(int i=1;i<=n;i++){ t=i; while(t){ if(t%10==1) ans++; t/=10; } } cout<<ans; return 0; }


Judgement Protocol: