글
[LuckyAlgorithm]Ice Cream Parlor(18/77)
Algorithm
2017. 11. 29. 12:20
import java.util.Scanner;
public class Main {
static void calculate(int[] price,int dollars) {
for(int g=1;g<price.length;g++) {
for(int k=g-1;k>=0;k--) {
if(price[g]+price[k] == dollars) System.out.println((k+1)+" "+(g+1));
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int recursive = s.nextInt();
for(int i=0;i<recursive;i++) {
int dollars = s.nextInt();
int flavors = s.nextInt();
int price[] = new int[flavors];
for(int j = 0;j<price.length;j++) {
price[j] = s.nextInt();
}
calculate(price,dollars);
}
}
}
'Algorithm' 카테고리의 다른 글
[LuckyAlgorithm]Alternating Characters (20/77) (0) | 2017.12.13 |
---|---|
[LuckyAlgorithm]Correctness and the Loop Invariant(19/77) (0) | 2017.11.29 |
[LuckyAlgorithm]Divisible Sum Pairs (17/77) (0) | 2017.10.23 |
[LuckyAlgorithm]Breaking the Records(16/77) (0) | 2017.10.23 |
[LuckyAlgorithm]Intro to Tutorial Challenges (15/77) (0) | 2017.10.23 |