Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
||||||||
2012-12-19 19:23:06 Secret
sol_id 8303602 i'm getting WA,plz check my solution.. Last edit: 2012-12-19 20:06:25 |
||||||||
2012-12-19 19:10:10 surprise
use long long :D |
||||||||
2012-12-19 18:24:14 aristofanis
Nice one! |
||||||||
2012-12-08 13:26:27 Arianto Wibowo
@ɥsǝןǝǝu that is 4 |
||||||||
2012-10-21 15:00:42 ɥsǝןǝǝu
what will be the output for..... 1 10 4 9 1 9 1 reply please.... |
||||||||
2012-10-15 01:30:42 Ahmed Abo El Kheir
@AUC LOCAL "0 <= C[i] < 10^3" gives wrong ans, but "0 <= C[i] <= 10^3" gave me accepted Last edit: 2012-10-15 01:31:11 |