#CCBOTPBA0000011. Đếm ngày thứ bảy/chủ nhật (Count Weekend Days)
Đếm ngày thứ bảy/chủ nhật (Count Weekend Days)
Count Weekend Days
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n consecutive days whose first weekday is w (Monday=1, …, Saturday=6, Sunday=7), count Saturdays and Sundays among these n days; weekdays wrap around after Sunday.
Input
One line contains n w.
Output
Print the number of weekend days.
Subtasks
-
Subtask 1 (20%):
n ≤ 14, weekday1..7. -
Subtask 2 (30%):
n ≤ 365, weekday1..7. -
Subtask 3 (50%):
n ≤ 10^6, weekday1..7.
Examples
Example 1
Input:
5 5
Output:
2
Explanation: The weekdays are 5,6,7,1,2; only 6 and 7 are weekends.
Example 2
Input:
7 1
Output:
2
Explanation: A full week contains two weekend days.
Example 3
Input:
1 7
Output:
1
Explanation: The only day is Sunday.