LCPC12F - Johnny The Gambler
Johnny is a gambling addict. He entered a casino and started playing a game with the dealer. The game is as follows: the dealer deals a sequence of N cards, each card containing a number C[i] and asks Johnny how many pairs (j, k) such that j < k and C[j] + C[k] = X. If Johnny answers correctly he wins, otherwise the dealer wins.
Input
The first line of input contains an integer T, the number of test cases. T test cases follow, Each test case start with the value of 0 ≤ X ≤ 2*103 followed by the number of cards 0 < N ≤ 105 followed by N numbers representing the numbers on the cards 0 ≤ C[i] ≤ 103.
Output
There should be T lines, containing the following format.
k. S
Where k is the test case number (starting at 1), a single period, a single space and S representing the number of valid pairs (j, k) as described above.
Sample
Input 1 10 3 1 5 9 Output 1. 1
hide comments
Abhinandan Agarwal:
2015-02-24 23:28:14
Constraints are correct, if you want include the test case, but declare the variable- which is supposed to store the answer, as long long, because answer can be large |
|
rishabh aggarwal:
2015-01-11 20:09:11
bad constraints.
|
|
Vipul Srivastava:
2014-12-22 10:00:42
Plz update the constraints, errors due to them are frustrating.. |
|
mkrjn99:
2014-10-03 16:16:39
The output format caused me 3 WA's. Frustrating! |
|
albertg:
2014-09-25 19:17:39
0<=C[i]<=(!)<=1000 |
|
Deepak Gupta:
2014-09-17 21:30:37
int gave WA, long long AC |
|
shiva:
2014-08-20 15:09:41
WA :(
|
|
pranjuldb:
2014-05-20 16:29:59
Cakewalk ! |
|
Pranye Mawai:
2013-12-23 18:44:02
use long long for your countin variabl..
|
|
fitcat:
2013-09-20 04:12:19
If I had read LeppyR64's comment, I would avoid the SIGSEGV errors and my own assertions. Problem setter: please fix it. |
Added by: | Gareev |
Date: | 2012-10-06 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | LCPC 2012 |