#QHD0000058. Tổng của các số nguyên tố phân biệt (Sum of Different Primes)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tổng của các số nguyên tố phân biệt (Sum of Different Primes)
Sum of Different Primes
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer may be expressed as the sum of distinct prime numbers. For example, gives two different sets of three primes.
Given positive integers and , count the sets of exactly pairwise distinct primes whose sum is . Order does not matter, so and represent the same choice. Each prime can be used at most once. The number is not a prime.
Print the exact number of such sets, with no modulus. For the stated limits, the answer is less than .
Input
A single line contains positive integers . There is no terminating 0 0 pair.
Output
Print one nonnegative integer: the number of sets of exactly distinct primes summing to .
Subtasks
-
Subtask 1 (20 points): , ; use distinct positive primes not exceeding .
-
Subtask 2 (30 points): , ; use distinct positive primes not exceeding .
-
Subtask 3 (50 points): , ; use distinct positive primes not exceeding ; the answer is below .
Examples
Input
24 3
Output
2
Explanation
The only sets of three distinct primes summing to are and . Permuting elements of a set does not create a new representation; the output is 2. With , the valid sets are , , and .