알고리즘
[알고리즘] 백준 2999 - 비밀 이메일 (C++)
blueberrysoda
2024. 12. 26. 23:26
[문제 링크] : https://www.acmicpc.net/problem/2999
#include <iostream>
#include <algorithm>
using namespace std;
char Arr[51][51];
int main(){
int R = 0, C = 0, T = 0;
string S;
cin >> S;
for(int i=1; i<=S.size(); i++){
if(S.size() % i == 0 && S.size() / i >= i){
if(S.size() / i > R){
R = i;
C = S.size() / i;
}
}
}
for(int i=0; i<C; i++){
for(int j=0; j<R; j++){
Arr[j][i] = S[T++];
}
}
for(int i=0; i<R; i++){
for(int j=0; j<C; j++){
cout << Arr[i][j];
}
}
cout << "\n";
return 0;
}