본문 바로가기
Algorithm/BOJ

[백준/BOJ] 2783번 - 삼각김밥 (C++)

by shine-jung 2022. 3. 23.
반응형

문제 링크


코드

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double ans;
    int x, y, n;
    cin >> x >> y >> n;
    ans = (double)x / y;
    while (n--) {
        cin >> x >> y;
        ans = min((double)x / y, ans);
    }
    cout << fixed;
    cout.precision(2);
    cout << ans * 1000;
}



설명


fixed와 precision을 통해서 cout에서 소수점 자릿수를 조절할 수 있다.




(주의) 기록용으로 작성한 글입니다. 좋은 코드가 아닐 수 있습니다.

댓글 환영합니다!


반응형

댓글