Problem
You receive a credit C at a local store and wowould like to buy two items. you first walk through the store and create a list l of all available items. from this list you wowould like to buy two items that add up to the entire value of the credit. the solution you provide will consist of the two integers indicating the positions of the items in your list (smaller number first ).
Input
The first line of input gives the number of cases, N. N test cases follow. For each test case there will be:
One line containing the value C, the amount of credit you have at the store.
One line containing the value I, the number of items in the store.
One line containing a space separated list of I integers. Each integer p indicates the price of an item in the store.
Each test case will have exactly one solution.
Output
For each test case, output one line containing "case # X:" followed by the indices of the two items whose price adds up to the store credit. The lower index shocould be output first.
Limits
5 ≤ C ≤ 1000
1 ≤ p ≤ 1000
Small Dataset
N = 10
3 ≤ I ≤100
Large Dataset
N = 50
3 ≤ I ≤2000
Sample
/** Author: WXG */# include <iostream> # include <vector> # include <stdio. h> using namespace STD; void solution () {int N; vector <int> C, L, First, Second, Max; vector <int> P; int I, j; CIN> N; for (I = 0; I <n; I ++) {int CTMP, ltmp; vector <int> pTMP; cin> CTMP> ltmp; C. push_back (CTMP); L. push_back (ltmp); For (j = 0; j <ltmp; j ++) {int vtmp; CIN> vtmp; pTMP. push_back (vtmp);} p. push_back (pTMP) ;}for (I = 0; I <n; I ++) {int CTMP = C. at (I); int Np = L. at (I); int max = 0, ftmp, stmp; For (j = 0; j <NP; j ++) {for (int K = J + 1; k <NP; k ++) {int mtmp = P. at (I ). at (j) + P. at (I ). at (k); If (max <mtmp & mtmp <= CTMP) {max = mtmp; ftmp = J; stmp = K ;}} first. push_back (ftmp + 1); Second. push_back (stmp + 1) ;}for (I = 0; I <n; I ++) {cout <"case #" <I + 1 <": "<first. at (I) <"" <second. at (I) <Endl ;}int main () {freopen ("A-large-practice.in", "r", stdin ); // redirect standard input and output streams freopen ("output.txt", "W", stdout); solution (); fclose (stdin); fclose (stdout); Return 0 ;}