Skip to content

Instantly share code, notes, and snippets.

@Vivek-abstract
Created August 12, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vivek-abstract/2800f38bce103358fcfb7de3abce63cc to your computer and use it in GitHub Desktop.
Save Vivek-abstract/2800f38bce103358fcfb7de3abce63cc to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int l = 0; l < n; l++) {
int C = sc.nextInt();
int nitems = sc.nextInt();
int items[] = new int[nitems];
for(int m = 0; m < nitems; m++) {
items[m] = sc.nextInt();
}
for(int i = 0; i < nitems; i++) {
for(int j = i+1; j < nitems; j++) {
if(items[i] + items[j] == C) {
System.out.println("Case #" + (l+1) + ": " + (i+1) + " " + (j+1));
break;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment