BOJ 10250 ACM 호텔

Jmnote bot (토론 | 기여)님의 2021년 7월 18일 (일) 05:45 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))

1 개요

BOJ 10250 ACM 호텔

[[분류:BOJ {{{단계}}}단계]]

  • 호텔 방 번호의 규칙을 찾아 출력하는 문제
BOJ 단계별로 풀어보기
순번 문제 풀이

틀:BOJ 8단계 틀:BOJ 단계 푸터

2 Java

import java.util.Scanner;
public class Main {
    private static int getRoom(int h, int w, int n) {
        int y = n % h;
        int x = n / h + 1;
        if( y == 0 ) {
            x--;
            y = h;
        }
        return 100*y + x;
    }
    
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int c = sc.nextInt();
		for (int i=0; i<c; i++) {
		    int h = sc.nextInt();
		    int w = sc.nextInt();
		    int n = sc.nextInt();
		    System.out.println( getRoom(h,w,n) );
		}
	}
}

3 PHP

<?php
$tt = intval(fgets(STDIN));
for($t=0; $t<$tt; $t++) {
    fscanf(STDIN, '%d %d %d', $h, $w, $n);
    echo ($n-1)%$h*100 + intdiv($n-1,$h) + 101 . "\n";
}

4 Python

tt = int(input())
for t in range(tt):
    h, w, n = map(int,input().split())
    print( (n-1)%h*100 + (n-1)//h + 101 )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}