标签:return nec bsp print += ace case code c++
本来应该是个数位dp的题的,结果暴力就过了
#include<bits/stdc++.h> using namespace std; const int maxN=100005; int cnt[maxN]; int onecnt(int x){ int u=10; int res=0; while(x>0){ if(x%u==1)res+=1; x/=10; } return res; } int main(){ cnt[0]=0; for(int i=1;i<maxN;i++)cnt[i]=cnt[i-1]+onecnt(i); int n,u; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&u); printf("case #%d:\n%d\n",i,cnt[u]); } }
标签:return nec bsp print += ace case code c++
原文地址:https://www.cnblogs.com/TAMING/p/9071383.html