안녕하세요. 오늘은 스키테일 암호를 해독할 거예요.

문제

https://www.acmicpc.net/problem/23080

아이디어

idx가 0부터 시작해서 K씩 증가시키면서 s[idx]를 출력해주면 됩니다.

소스코드

#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(void)
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    ll idx = 0, K;
    cin >> K >> s;
    while (idx < s.length())
    {
        cout << s[idx];
        idx += K;
    }
}


감사합니다.

0개의 댓글