Help with digit DP problem

Revision en2, by Reslan, 2016-08-08 15:35:32

Hello codeforces :D

I was trying to solve this problem

and I got TLE , I tried to solve it using DP.

my approach for this problem , first I find how many 369 are there in the interval [ 1 , B ] , let this value be right

then I find how many 369 are there in the interval [ 1 , A ] , let this value be left

my final answer will be right — left , if A is not 369 number

else it will be : right — left + 1

here is my code

can I do some pre calculations to avoid TLE ?

thank in advance :D

Tags #dp, digit dp, spoj, dynamic programming

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Reslan 2016-08-08 15:35:32 413
en1 English Reslan 2016-08-08 13:36:30 214 Initial revision (published)