JPM - Just Primes
InputThe first line contains an integer T, denoting the number of test cases. Each of the next subsequent T lines contain a positive integer N.
OutputFor each test case, first print the case number followed by the minimum number of distinct primes such that their sum equals to N. If N cannot be represented by a summation of distinct primes, then print the case number followed by -1. Refer to the sample input/output for more clarity of the format.
10 1 2 3 10 27 100 1000 4572 4991 49999
Case 1: -1 Case 2: 1 Case 3: 1 Case 4: 2 Case 5: 3 Case 6: 2 Case 7: 2 Case 8: 2 Case 9: 3 Case 10: 1
ChallengeToo easy? Try the harder version here - Just Primes II
Scape, pls look into recent streak of submissions from CVR College Of Engineering users. Except for Shirisha, they normally code in C or Python, yet here they all switched to Java and magically came up with almost exactly equally performing code.
Too easy!! Classic coin change problem.