PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000131. Tổng các số nguyên tố liên tiếp (Sum of Consecutive Prime Numbers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng các số nguyên tố liên tiếp (Sum of Consecutive Prime Numbers)
Sum of Consecutive Prime Numbers
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , consider the increasing prime sequence . Count representations of as the sum of one or more consecutive elements of this prime sequence. A single prime counts as one representation. The chosen primes must be consecutive in the sequence.
Input
One line containing the integer .
Output
Print one integer: the number of representations.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
41
Output
3
Explanation
For , exactly three consecutive-prime segments sum to : , , and the one-element segment . Hence print 3.