#CCBCHMUOI0000033. Rơi xuyên ba nhánh (Three-Case Fallthrough)
Rơi xuyên ba nhánh (Three-Case Fallthrough)
Three-Case Fallthrough
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Start with s = 0 and execute switch(k): case 1 adds 1, case 2 adds 2, and case 3 adds 3 then breaks. There is deliberately no break after cases 1 and 2; default sets s = 0. Print the final s.
Input
One integer k.
Output
Print the final s.
Subtasks
- Subtask 1 (20%): 1 <= k <= 2.
- Subtask 2 (30%): 1 <= k <= 3.
- Subtask 3 (50%): -10^9 <= k <= 10^9.
Examples
Example 1
Input
1
Output
6
Explanation
Starting in case 1 adds 1, then 2, then 3, giving 6.
Example 2
Input
2
Output
5
Explanation
Starting in case 2 adds 2 and 3 only, giving 5.