Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 |
| 31 |
Tags
- COS PRO
- 백준
- db
- Java
- 운동기록
- 자바
- 문자열
- BOJ
- math
- dfs
- 러닝일지
- 건강
- SWEA
- 시뮬레이션
- binary search
- priorityqueue
- 문제해결
- greedy
- 이분탐색
- 프로그래머스
- 투포인터
- 코딩테스트
- SQL
- 알고리즘
- MySQL
- oracle
- 코테
- 문제풀이
- BFS
- DP
Archives
- Today
- Total
슈콩
[SWEA] 육십갑자 본문


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYzIZNkq-v4DFAQ9
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int m = Integer.parseInt(st.nextToken());
String[] s = new String[n];
String[] t = new String[m];
st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
s[i] = st.nextToken();
}
st = new StringTokenizer(br.readLine());
for(int i=0;i<m;i++) {
t[i] = st.nextToken();
}
System.out.print("#"+tc+" ");
int q = Integer.parseInt(br.readLine());
for(int i=0;i<q;i++) {
int year = Integer.parseInt(br.readLine());
int a = year % n;
if(a==0) a = n-1;
else a--;
int b = year % m;
if(b==0) b = m-1;
else b--;
System.out.print(s[a]+t[b]+" ");
}
System.out.println();
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 주혁이의 복권 당첨 (0) | 2025.11.25 |
|---|---|
| [SWEA] 방울 마술 (0) | 2025.11.23 |
| [SWEA] 문자열 교집합 (0) | 2025.11.22 |
| [SWEA] 두 수의 덧셈 (0) | 2025.11.21 |
| [SWEA] 다솔이의 월급 상자 (0) | 2025.11.21 |