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
- SWEA
- db
- BFS
- 프로그래머스
- 건강
- MySQL
- 투포인터
- binary search
- math
- DP
- Java
- 이분탐색
- dfs
- 러닝일지
- priorityqueue
- 문제해결
- oracle
- greedy
- 코테
- 코딩테스트
- 운동기록
- BOJ
- 백준
- 자바
- 알고리즘
- 문자열
- 문제풀이
- 시뮬레이션
- COS PRO
- SQL
Archives
- Today
- Total
슈콩
[SWEA] 규영이와 인영이의 카드게임 본문


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWgv9va6HnkDFAW0
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.util.*;
import java.io.*;
public class Solution {
static int resultA,resultB;
static int[] a = new int[9];
static int[] b = new int[9];
static boolean[] card;
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());
card = new boolean[19];
for(int i=0;i<9;i++) {
int v = Integer.parseInt(st.nextToken());
card[v] = true;
a[i] = v;
}
resultA = resultB = 0;
combi(0);
System.out.println("#"+tc+" "+resultA+" "+resultB);
}
}
private static void combi(int cnt) {
if(cnt==9) {
game();
return;
}
for(int i=1;i<=18;i++) {
if(!card[i]) {
card[i] = true;
b[cnt] = i;
combi(cnt+1);
card[i] = false;
}
}
}
private static void game() {
int score = 0;
for(int i=0;i<9;i++) {
if(a[i]>b[i]) {
score += (a[i] + b[i]);
}
else if(a[i]<b[i]) {
score -= (a[i] + b[i]);
}
}
if(score>0) resultA++;
if(score<0) resultB++;
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 교환학생 (0) | 2025.11.11 |
|---|---|
| [SWEA] 10일차 - 비밀번호 (0) | 2025.11.10 |
| [SWEA] 3일차 - String (0) | 2025.11.10 |
| [SWEA] 0/1 Knapsack (0) | 2025.11.10 |
| [SWEA] 단순 2진 암호코드 (0) | 2025.11.09 |