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
hide comments
Ishan:
2023-03-29 05:47:09
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 ?
|
|
dwij28:
2016-10-05 09:09:51
Stuck at 203 chars. :/ |
|
RIVU DAS:
2015-02-16 14:49:29
Awesome problem!!! Learnt a lot :) |
|
numerix:
2015-02-16 14:49:29
@Mitch: 131 Bytes are out of reach at the moment and I have little motivation to spend more time on that problem. |
|
Mitch Schwartz:
2015-02-16 14:49:29
@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 |
|
numerix:
2015-02-16 14:49:29
@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. |
|
Mitch Schwartz:
2015-02-16 14:49:29
I made a comment around the time this problem was published and it has annoyingly been deleted. Here is a screenshot:
|
|
Mitch Schwartz:
2015-02-16 14:49:29
@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.
|
|
numerix:
2015-02-16 14:49:29
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. :( |
|
]V[AgN3To:
2015-02-16 14:49:29
whooa !!
|
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 |