BOJ 문제풀이

백준 10250번 C 언어 풀이

koreasunoo 2021. 7. 9. 22:31

안녕하세요 오늘은 나누기/나머지 개념으로 풀 수 있는 문제입니다.

코드:

#include <stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    for(int i = 0; i<a; i++){
        int h, w, n;
        scanf("%d %d %d",&h, &w, &n);
        int ho, floor;
        if(n%h == 0){
            ho = n/h;
            floor = h;
        }
        else{
            ho = n/h+1;
            floor = n%h;
        }
        printf("%d\n",100*floor + ho);

    }
    return 0;
}

설명:

왜 n/h와 n%h가 코드에 쓰였는지 잘 생각해보시길 바랍니다

 

'BOJ 문제풀이' 카테고리의 다른 글

백준 11729번 파이썬 풀이  (0) 2021.07.15
백준 1436번 C언어 풀이  (0) 2021.07.11
백준 2439번 C언어 풀이  (0) 2021.07.09
백준 2438번 C언어 풀이  (0) 2021.07.09
백준 11022번 C언어 풀이  (0) 2021.07.09