백준 5426번: 비밀 편지 #Python

ColorlessDia·2025년 1월 6일

algorithm/baekjoon

목록 보기
414/809
import sys

T = int(sys.stdin.readline())

for _ in range(T):
    ciphertext = sys.stdin.readline().rstrip()

    size = int(len(ciphertext) ** 0.5)

    plaintext = ''

    for i in range(size, 0, -1):
        j = i
        
        for _ in range(size):
            plaintext += ciphertext[j - 1]

            j += size
    
    print(plaintext)

0개의 댓글