문자열(String)
백준 2675번: 문자열 반복
cepiloth
2018. 7. 3. 10:19
반응형
https://www.acmicpc.net/problem/2675
1. 문제
문자열의 길이 만큼 하나의 단어를 출력 하는 문제.
2. 알고리즘
키워드 - 구현
처음 알고리즘을 시작 할때는 부르트포스 문제로 생각 했는데 지금 와서 보니 단순 구현 문제다.
3. 코드
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 | #include <iostream> #include <algorithm> // min #include <math.h> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int cand = 0; string word; cin >> cand >> word; int size = word.size(); for (int j = 0; j < size; j++) { for (int k = 0; k < cand; k++) { cout << word[j]; } } printf("\n"); } return 0; } | cs |
반응형