P19941 [GeeksforGeeks] Sum of k primes0056
普及-
题目描述

Given two numbers N and K. Find out if ‘N’ can be written as a sum of ‘K’ prime numbers.
Input:
N = 10 and K = 2
Output: 1
Explanation:
10 can be written as 5 + 5

Example 2:
Input:
N = 2 and K = 2
Output: 0
Your Task:
You don't need to read input or print anything. Your task is to complete the function isSumOfKprimes() which takes the integer N and an integer K as input parameters and returns the true if N can be expressed as a sum of K primes else return false.
If function returns true, driver code will print 1 in output and 0 if the function returns false.
Expected Time Complexity: O(SQRT(N))
Expected Auxiliary Space: O(1)

Constraints:
1 <= N,K <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
N = 10 and K = 2
样例输出
1