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

 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
* {{BOJ|10250}}
[[분류: BOJ]]
;{{PAGENAME}}
* 호텔 방 번호의 규칙을 찾아 출력하는 문제
* 호텔 방 번호의 규칙을 찾아 출력하는 문제
{{BOJ 단계 헤더}}
{{BOJ 8단계}}
{{BOJ 단계 푸터}}


==Java==
==Java==
<source lang='java'>
<syntaxhighlight lang='java'>
import java.util.Scanner;
import java.util.Scanner;
public class Main {
public class Main {
32번째 줄: 29번째 줄:
}
}
}
}
</source>
</syntaxhighlight>


==PHP==
==PHP==
<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php
$tt = intval(fgets(STDIN));
$tt = intval(fgets(STDIN));
42번째 줄: 39번째 줄:
     echo ($n-1)%$h*100 + intdiv($n-1,$h) + 101 . "\n";
     echo ($n-1)%$h*100 + intdiv($n-1,$h) + 101 . "\n";
}
}
</source>
</syntaxhighlight>


==Python==
==Python==
<source lang='python'>
<syntaxhighlight lang='python'>
tt = int(input())
tt = int(input())
for t in range(tt):
for t in range(tt):
     h, w, n = map(int,input().split())
     h, w, n = map(int,input().split())
     print( (n-1)%h*100 + (n-1)//h + 101 )
     print( (n-1)%h*100 + (n-1)//h + 101 )
</source>
</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 }}