이번 문제는 문제를 푸는데 시간이 좀 걸렸다.
나누기를 할때 정확히 나누어 떨어지면 만약 6층인데 6번째 손님이 오면 나머지가 0이 되기 때문에 이를 어떻게 6으로 출력할지 고민을 했던것 같다.
package baek10250;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int testcase = Integer.parseInt(bf.readLine());
StringTokenizer st;
String string = "";
int h, w, n;
for (int i = 0; i < testcase ; i++) {
string = bf.readLine();
st = new StringTokenizer(string);
h = Integer.parseInt(st.nextToken());
w = Integer.parseInt(st.nextToken());
n = Integer.parseInt(st.nextToken());
calculate(h, w, n);
}
}
public static void calculate(int h, int w, int n) {
int dong;
int ho;
dong = (n%h) == 0 ? h : (n%h);
ho = (n%h) == 0? (n/h) : (n/h)+1;
System.out.printf("%d%02d\n",dong,ho);
}
}
그래도 잘 풀어서 다행이다.
'알고리즘' 카테고리의 다른 글
백준 알고리즘 1978 - 소수 찾기 (0) | 2020.03.31 |
---|---|
백준 알고리즘 1011 - Fly me to the Alpha Centauri (0) | 2020.03.23 |
백준 알고리즘 2775 - 부녀회장이 되고싶어 (0) | 2020.03.21 |
댓글