본문 바로가기

Algorithm

C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2783번:삼각 김밥 답

반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
int main() {
    double sx, sy, x, y;
    double scost, ocost;
    int n;
 
    cin >> sx >> sy;
    cin >> n;
 
    scost = sx / sy * 1000;
 
    while (n--)
    {
        cin >> x >> y;
 
        ocost = x / y * 1000;
 
        if (scost > ocost)
            scost = ocost;
    }
 
    printf("%.2f\n", scost);
}
cs