ICANDIES - Candies
Sava is a student of class X. She has two little sisters Sara and Sami. Sara is only 3 years old and Sami is a girl of 5 years. At her birthday Sava bought N candies and wants to divide them between her two sisters Sara and Sami. But as Sara is 3 years old she wants such amount of candies that is perfectly divisible by 3. Sami also wants the amount of her candies to be perfectly divisible by 5 and only this way both of them are happy otherwise they become unhappy.
So, Sava wants to make both of them happy. Now for some value of N Sava can divide the candies in various ratio that will make her sisters happy. But as Sara is the youngest one she wants to give the maximum number of candies she can. As Sava is not good enough in math, she wants your help.
Input
Input starts with an integer T (1≤T≤50), denoting the number of test cases. Each of the test cases consists an integer N (1≤N≤106), the number of candies Sava bought.
Output
For each case print "Case X: " where X (1≤X≤T) is the case number. And then, if it is possible to divide the candies making both of them happy print the maximum number of candies you can give to Sara. And if it is not possible to make both of them happy then print '-1' (without the quotes).
Example
Input: 3 8 9 20 Output: Case 1: 3 Case 2: -1 Case 3: 15
hide comments
sandilya1599:
2019-07-11 08:26:56
What is expected complexity for each case?
|
|
singlasahil221:
2018-04-04 16:07:14
Weak testcases. |
|
zeeshan12:
2018-01-16 16:37:12
there is no blank line after each output |
|
secrets_inside:
2017-10-22 03:09:34
those who are getting WA, must check for test cases that are multiple of 5*3
|
|
viratian_070:
2017-07-07 19:22:51
my century....and it is the beginning...very easy problem |
|
shubham_cs_iet:
2017-02-07 15:48:58
Yooo....!!! my century....after 4 WA.....:))). |
|
phrs_91:
2017-02-05 13:08:53
Yooo...!!! my half century |
|
aravind1997:
2016-08-07 18:01:51
easy one :) ac in one go..
|
|
shashisuman:
2016-07-01 19:39:21
its not hard to code!! its hard to find where the author wants spaces !!!! |
|
Piyush Kumar:
2016-05-28 13:52:09
Should be moved to tutorial.
|
Added by: | imranziad |
Date: | 2015-10-07 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | AIUB Beginners Team Formation Contest (Round 5) Onsite |