https://www.swexpertacademy.com/main/learn/course/lectureProblemViewer.do
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cmath> #include <stdlib.h> using namespace std; int main() { int t; int result_cnt = 1; cin >> t; while (t--) { int row, col; int ten[10] = { 13, 25, 19, 61, 35, 49, 47, 59, 55, 11 }; // 암호해독 코드들 10진수 표현 int lastOne_row = 0; // 암호의 마지막 1로 CHECK int lastOne_col = 0; char arr[51][101] = { 0, }; // 입력될 영상 + 암호 char secret[60] = { 0, }; // 해독 당할 (7x8)=56 개의 암호들 int secret_code[10] = { 0, }; // 해독해서 암호코드로 변환 cin >> row >> col; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { cin >> arr[i][j]; if (arr[i][j] == '1') { lastOne_row = i; lastOne_col = j; } } } int code_start = lastOne_col - 55; int cnt = 6; int k = 0; for (int i = 0; i < 56; i++) { secret[i] = arr[lastOne_row][code_start + i]; if (secret[i] == '1') { secret_code[k] += pow(2, cnt); } if ((i + 1) % 7 == 0) { k++; cnt = 7; } cnt--; } for (int i = 0; i < 8; i++) { for (int j = 0; j < 10; j++) { if (ten[j] == secret_code[i]) { secret_code[i] = j; } } } int check = (secret_code[0] + secret_code[2] + secret_code[4] + secret_code[6]) * 3 + secret_code[1] + secret_code[3] + secret_code[5] + secret_code[7]; if (check != 0 && check % 10 == 0) { int sum = 0; for (int i = 0; i < 8; i++) { sum += secret_code[i]; } printf("#%d %d\n", result_cnt, sum); } else { printf("#%d 0\n", result_cnt); } result_cnt++; } return 0; } | cs |
'NOTE > Algorithm' 카테고리의 다른 글
[visualgo.net] 자료구조와 알고리즘의 시각화 사이트 (0) | 2024.05.10 |
---|---|
[프로그래머스] 폰켓몬 _ 해시 _ C++ (0) | 2024.05.10 |
[알고리즘문제] acmicpc_벌집 (0) | 2018.04.01 |
[알고리즘문제] acmicpc_단어의개수 (0) | 2018.04.01 |
[알고리즘문제] 평균점수 / 숫자의 개수 (0) | 2018.04.01 |