CST Training assignment 4 solved

$30.00

Category: Tags: , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

Question-1
Given an integer N, the task is to count the number of ways so that N can be written as the sum of a prime
number and twice of a square, i.e. N = 2*A2 + P, where P can be any prime number and A is any positive
integer.
Input: N = 9
Output: 1
Explanation:
9 can be represented as sum of prime number and twice a square in only one way –
N = 9 = 7 + 2*(12
)
Input: N = 15
Output: 2
Explanation:
15 can be represented as sum of prime number and twice a square in two ways –
N = 15 = 7 + 2 * (22
)
N = 15 = 13 + 2 * (12
)
Question-2
Given a large integer as a string str, the task is find the number of matchsticks required to represent it.
Input: str = “56”
Output: 11
Explanation: 5 sticks are required to represent 5 and 6 sticks are required to represent 6.