"BOJ 10250 ACM 호텔"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
1번째 줄: 1번째 줄:
==개요==
==개요==
* {{BOJ|10250}}
[[분류: BOJ]]
;{{PAGENAME}}
* 호텔 방 번호의 규칙을 찾아 출력하는 문제
* 호텔 방 번호의 규칙을 찾아 출력하는 문제
{{BOJ 단계 헤더}}
{{BOJ 8단계}}
{{BOJ 단계 푸터}}


==Java==
==Java==
51번째 줄: 48번째 줄:
     print( (n-1)%h*100 + (n-1)//h + 101 )
     print( (n-1)%h*100 + (n-1)//h + 101 )
</syntaxhighlight>
</syntaxhighlight>
[[분류:BOJ 8단계]]

2023년 8월 26일 (토) 19:21 기준 최신판

1 개요[ | ]

BOJ 10250 ACM 호텔
  • 호텔 방 번호의 규칙을 찾아 출력하는 문제

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 }}