fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. //To take input from file and send output to file from standard input/output use freopen()
  11. //freopen("A-large-practice.in","r",stdin);
  12. //freopen("output.txt","w",stdout);
  13. int n;
  14. cin >> n;
  15. for (int k = 1; k <= n; k++) {
  16. int credit,num,price;
  17. cin >> credit >> num;
  18.  
  19. int p[num];
  20. for (int i=0; i<num; i++) {
  21. cin >> p[i];
  22. }
  23.  
  24. for (int i = 0; i < num-1; i++) {
  25. for (int j = i+1; j < num; j++) {
  26. if (p[i]+p[j]==credit)
  27. cout << "Case #" << k << ": " << i+1 << " " << j+1 << endl;
  28. }
  29. }
  30. }
  31. }
  32.  
Success #stdin #stdout 0s 3460KB
stdin
3
100
3
5 75 25
200
7
150 24 79 50 88 345 3
8
8
2 1 9 4 4 56 90 3
stdout
Case #1: 2 3
Case #2: 1 4
Case #3: 4 5