B. Making Sequences is Fun 暴力比较水
const int maxn = 30000; int digit(LL x) { int ans = 0; while(x) { x/=10; ans++; } return ans; } LL p10(int x) { LL ans = 1; repf(i,1,x) ans *= 10; return ans; } int main() { //freopen("in.txt","r",stdin); LL w,m,k; while(cin>>w>>m>>k) { LL ans = 0; int d = digit(m); LL Max = 0; repf(i,1,d) Max = Max*10 + 9; LL L = Max - m + 1; if(L >= w/((LL)d*k)) { ans = w/((LL)d*k); }else { ans += L; w -= L*(LL)d*k; int e = d+1; for(int i = d+1;i <= 17;++i) { LL P = p10(i-1)*9; if(w/((LL)i*k) >= P ) { w -= P*(LL)i*k; ans += P; }else { e = i; break; } } if(w >= (LL)e*k) { ans += w / ((LL)e*k); } } cout<<ans<<endl; } return 0; }
posted on 2013-12-15 16:41 keep trying 阅读(486) 评论(0) 编辑 收藏 举报