Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Tags
more
Archives
Today
Total
관리 메뉴

코드와이

[BAEKJOON] 10158. 개미 본문

acmicpc

[BAEKJOON] 10158. 개미

코드와이 2021. 2. 26. 10:34

 

문제링크

www.acmicpc.net/problem/10158

 

10158번: 개미

가로 길이가 w이고 세로 길이가 h인 2차원 격자 공간이 있다. 이 격자는 아래 그림처럼 왼쪽 아래가 (0,0)이고 오른쪽 위가 (w,h)이다. 이 공간 안의 좌표 (p,q)에 개미 한 마리가 놓여있다. 개미는 오

www.acmicpc.net

 

package acmicpc.Siver2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class 개미 {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		StringBuilder sb = new StringBuilder();
		
		int w = Integer.parseInt(st.nextToken());
		int h = Integer.parseInt(st.nextToken());
		
		st = new StringTokenizer(br.readLine());
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		
		int t = Integer.parseInt(br.readLine());
		
		x += t;
		y += t;
		
		x %= (2 * w);
		y %= (2 * h);
		
		if(x > w) x = 2 * w - x;
		if(y > h) y = 2 * h - y;
		sb.append(x).append(" ").append(y);
		
		System.out.println(sb);
	}
}

'acmicpc' 카테고리의 다른 글

[BAEKJOON] 1929. 소수 구하기  (0) 2021.03.01
[BAEKJOON] 2564경비원  (0) 2021.02.26
[BAEKJOON] 10799. 쇠막대기  (0) 2021.02.26
[BAEKJOON] 2669. 직사각형 네개의 합집합의 면적 구하기  (0) 2021.02.26
[BAEKJOON] 2477. 참외밭  (0) 2021.02.24