Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
DEMSO - Đếm số |
English | Vietnamese |
For a natural number in the decimal number system, we define a bad position is a position in which the corresponding digit and the next digit is differenced by no more than D. If a number has no more than K bad positions, we call it a beautiful number.
Your task is to count the beautiful numbers in the interval (A, B).
Input
A single line consisting of four integers A, B, D, K.
Output
A single line consisting of the number of beautiful numbers in the interval (A, B).
Constraint
1 ≤ A ≤ B ≤ 1015
Example
Input 1 13 1 0 Output 10
Được gửi lên bởi: | VOJ problem setters |
Ngày: | 2008-06-07 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE |
Nguồn bài: | VNOI Marathon '08 - Practice Round Problem Setter: Khúc Anh Tuấn |