Java/백준
[java 백준] 브론즈 3/ 2783번 삼각 김밥
Meaning_
2021. 7. 17. 23:51
728x90
반응형
https://www.acmicpc.net/problem/2783
2783번: 삼각 김밥
첫째 줄에 세븐25의 삼각 김밥 가격 정보 X와 Y가 주어진다. (Y그램 당 X원) (1 ≤ X ≤ 100, 1 ≤ Y ≤ 1,000) 둘째 줄에는 세븐25를 제외한 편의점의 개수 N이 주어진다. (1 ≤ N ≤ 100) 다음 N개의 줄에는 i
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int seven_x = sc.nextInt();
int seven_y = sc.nextInt();
double seven = (seven_x / (double) seven_y) * 1000;
int num = sc.nextInt();
double[] arr = new double[num + 1];
arr[0] = seven;
for (int i = 1; i < num + 1; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
double price = (x / (double) y) * 1000;
arr[i] = price;
}
Arrays.sort(arr);
System.out.println(String.format("%.2f", arr[0]));
}
}
|
cs |
728x90
반응형