Không hỗ trợ Mobile

Chế độ luyện tập yêu cầu môi trường màn hình lớn để làm bài và chống gian lận hiệu quả. Vui lòng truy cập bằng máy tính (Desktop/Laptop) để tiếp tục thao tác.

Quay lại trang chủ

#1917 · Zig-Zag Numbers

MÔ TẢ BÀI TOÁN

A positive integer is called a zig-zag number if the digits, when read from left to right, alternate between increasing and decreasing.

For example, 2947 is a zig-zag number because the sequence of its digits alternates between increasing (2 → 9) and decreasing (9 → 4) and then increasing again (4 → 7). Similarly, 71946 is a zig-zag number because its digits alternate between decreasing (7 → 1) and increasing (1 → 9) and so on. Conversely, numbers like 123, 71446, 71442, or 88 are not zig-zag numbers. Note that single-digit positive integers are considered zig-zag numbers.

Given integers A, B, and M, find the number of zig-zag numbers between A and B that are multiples of M, and output the count modulo 10000.

Dữ liệu vào

The input consists of 3 lines:

  • The first line contains the integer A.
  • The second line contains the integer B. The third line contains the integer M.

The values satisfy the constraints: 1≤A≤B≤10500 and 1≤M≤500. Note that A and B may be larger than standard integer types.

Dữ liệu ra

Print a single integer which is the count of zig-zag numbers between A and B that are multiples of M, modulo 10000.

BẢNG TỔNG QUAN KẾT QUẢ

# Tài khoản Kết suất Lúc nộp
1
Lê Duy Hải @2280600799
127 ms 16428 KB
7407 Bytes
12/08/2025
00:34
2
Lê Duy Hải @2280600799
135 ms 16436 KB
7407 Bytes
12/08/2025
00:34
3
Lê Duy Hải @2280600799
136 ms 16436 KB
7407 Bytes
12/08/2025
00:34
4
Lê Duy Hải @2280600799
138 ms 16424 KB
7407 Bytes
12/08/2025
00:34
5
Lê Duy Hải @2280600799
139 ms 16428 KB
7407 Bytes
12/08/2025
00:34
6
Lê Duy Hải @2280600799
139 ms 16428 KB
7407 Bytes
12/08/2025
00:34
7
Lê Duy Hải @2280600799
142 ms 16440 KB
7407 Bytes
12/08/2025
00:34
8
658 ms 836 KB
4222 Bytes
07/03/2025
01:51
9
693 ms 440 KB
3715 Bytes
07/03/2025
01:45
10
702 ms 440 KB
3669 Bytes
07/03/2025
01:49
11
704 ms 440 KB
3669 Bytes
07/03/2025
01:51
12
704 ms 444 KB
3669 Bytes
07/03/2025
01:46
13
704 ms 444 KB
3669 Bytes
07/03/2025
01:52
14
704 ms 448 KB
3669 Bytes
07/03/2025
01:47
15
704 ms 448 KB
3669 Bytes
07/03/2025
01:52
16
706 ms 440 KB
3669 Bytes
07/03/2025
01:52
17
707 ms 444 KB
3669 Bytes
07/03/2025
01:54
18
709 ms 440 KB
3669 Bytes
07/03/2025
01:52
19
709 ms 448 KB
3669 Bytes
07/03/2025
01:52
20
717 ms 444 KB
3715 Bytes
07/03/2025
01:45

LỊCH SỬ CÁ NHÂN

Vui lòng đăng nhập để xem lịch sử làm bài của bạn.

THẢO LUẬN BÀI TOÁN

Chưa có thảo luận nào cho bài này.

GỢI Ý & HƯỚNG DẪN

  • Explanation Example 1: There are 13 zig-zag numbers between 100 and 200 that are multiples of 5: 105, 120, 130, 140, 150, 160, 165, 170, 175, 180, 185, 190, and 195.
  • Explanation Example 2: There are 50246 zig-zag numbers between 6 and 1234567 that are multiples of 3. The result modulo 10000 is 246.
Viết code