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

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
8번째 줄: 8번째 줄:


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


==PHP==
==PHP==
<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php
$tt = intval(fgets(STDIN));
$tt = intval(fgets(STDIN));
42번째 줄: 42번째 줄:
     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단계]]
[[분류:BOJ 8단계]]

2021년 7월 18일 (일) 05:45 판

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