Submit | All submissions | Best solutions | Back to list |
GOV02 - Good |
The problem is very easy.
You are given n terms ( the terms can be integer as well as floating ). Let S = sum of all the n terms. A number k (x<=k<=y) is said to be good if S is divisible by it.
Input
Input begins with an integer t.
Then t test cases follow.
For each test case, three numbers n,x,y are given. Then n terms of the sequence follow.
(REMEMBER: all the input is on a single line)
Output
For each test case,
You have to output a single integer m.
where, m = (sum of all even good numbers) - ( number of all odd good numbers)
(REMEMBER: all the output should be on a single line)
The numbers should be separated by spaces.
Example
Input: 2 3 1 2 1 2 3 4 1 10.5 -1 4.5 4.5 4 Output:
1 10
Scoring:
Your task is to minimise the source code length.
The less your fingers work, more you gain.
Remember:
Only python 2.7 is permitted. Sorry in advance, I will not allow any other language.
Source limit is tight. So be careful.
Constraints:
1<=t<=10
1<=n<=100
-100<=any term of sequence<=100
0<x<=y<=100
Added by: | Govind Lahoti |
Date: | 2013-01-07 |
Time limit: | 0.5s |
Source limit: | 200B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | PYTHON |
Resource: | self |
hide comments
|
|||||
2023-03-29 05:47:09 Ishan
Can someone help me understand the 2nd case, S=-1+ 4.5+ 4.5+ 4=12, now good numbers between 1 and 10.5 are 1,2,3,4,6.Sum_even_good=2+4+6=12,Sum_odd_good=1+3=4, answer should be 12-4=8. what am I missing ? |
|||||
2016-10-05 09:09:51
Stuck at 203 chars. :/ |
|||||
2015-02-16 14:49:29 RIVU DAS
Awesome problem!!! Learnt a lot :) |
|||||
2015-02-16 14:49:29 numerix
@Mitch: 131 Bytes are out of reach at the moment and I have little motivation to spend more time on that problem. |
|||||
2015-02-16 14:49:29 Mitch Schwartz
@numerix: Thanks for the reply. I've found out the deprecated feature you're referring to, and was able to get AC 131 now with a workaround. I'll try to contact the author (but I know there have been dealings in the past, and he may not even have problem setting privileges anymore...). I'll keep the 126 up for now, but if it's unfairly preventing you from getting a top score let me know. Last edit: 2013-09-14 12:35:41 |
|||||
2015-02-16 14:49:29 numerix
@Mitch: I can reduce my codesize with Python 2.5 and, yes, it works if 10.5 is replaced by 10. But even with Python 2.5 I'm several bytes away from your 126 Bytes solution and I see no need that you should disqualify your own code. |
|||||
2015-02-16 14:49:29 Mitch Schwartz
I made a comment around the time this problem was published and it has annoyingly been deleted. Here is a screenshot: I should add now an Edit 3: that actually not all n,x,y are integers in the input, I was mistaken in that. Last edit: 2013-09-14 11:46:56 |
|||||
2015-02-16 14:49:29 Mitch Schwartz
@numerix: You're right, my old 126-byte solution now gets NZEC. I'm not sure if the author is around to do a rejudge. I want to look into what is making my code NZEC, I'll disqualify it before long I suppose. Edit: I'm trying to see whether NZEC is because of 2.5 -> 2.7 or possibly a change in the test data. @numerix could you tell me whether your shorter 2.5-only solution passes the sample input if 10.5 is changed to 10, on ideone? (My 126-byte does.) Last edit: 2013-09-14 02:22:54 |
|||||
2015-02-16 14:49:29 numerix
An unsatisfying situation: The Python interpreter has changed from 2.5 to 2.7 meanwhile. All former AC submissions were judged using Python 2.5 (as you can conclude from the memory consumption), but now Python 2.7 is running. That really matters, because Python 2.5 offered a - deprecated, but still allowed - possibility that Python 2.7 does no longer accept, but for this problem leads to shorter code. :( |
|||||
2015-02-16 14:49:29 ]V[AgN3To
whooa !! a simple mistake . . . huh finally AC :) Last edit: 2013-03-07 10:23:53 |