fork(8) download
  1. #include<stdio.h>
  2. typedef long long ll;
  3. ll get(ll a)
  4. {
  5. ll ret=0;
  6. ll now=1;
  7. ll t=1;
  8. for(;;)
  9. {
  10. if(now*10>a)
  11. {
  12. ret+=(a-now+1)*t;
  13. break;
  14. }
  15. ret+=now*9*t;
  16. now*=10;
  17. t++;
  18. }
  19. return ret;
  20. }
  21. int main()
  22. {
  23. ll gen,st,tim;
  24. scanf("%I64d%I64d%I64d",&gen,&st,&tim);
  25. gen/=tim;
  26. ll beg=st-1,end=20000000000000000LL;
  27. for(;;)
  28. {
  29. ll med=(beg+end)/2+1;
  30. if(get(med)-get(st-1)>gen)
  31. {
  32. end=med-1;
  33. }
  34. else
  35. {
  36. beg=med;
  37. }
  38. if(beg==end)
  39. {
  40. printf("%I64d\n",beg-st+1);
  41. break;
  42. }
  43. }
  44. }
Time limit exceeded #stdin #stdout 5s 3296KB
stdin
Standard input is empty
stdout
Standard output is empty