Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length k is vowelly if there are positive integers n and m such that n⋅m=k and when the word is written by using n rows and m columns (the first row is filled first, then the second and so on, with each row filled from left to right), every vowel of the English alphabet appears at least once in every row and every column.
You are given an integer k and you must either print a vowelly word of length k or print −1 if no such word exists.
In this problem the vowels of the English alphabet are ‘a’, ‘e’, ‘i’, ‘o’ ,‘u’.
Input
Input consists of a single line containing the integer k (1≤k≤104) — the required length.
Output
The output must consist of a single line, consisting of a vowelly word of length k consisting of lowercase English letters if it exists or −1 if it does not.
If there are multiple possible words, you may output any of them.
Examples
input
7
output
1
input
36
output
agoeuioaeiruuimaeoieauoweouoiaouimae
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int cmp(int x){
int flag=-1,i=5;
for(;i<=sqrt(x);i++){
if(x%i==0){
flag=i;break;
}
}
return flag;
}
int main(){
int k,i,j,h,w;
char ff[20][5];
ff[0][0]='a';ff[0][1]='e';ff[0][2]='i';ff[0][3]='o';ff[0][4]='u';
ff[1][0]='e';ff[1][1]='i';ff[1][2]='o';ff[1][3]='u';ff[1][4]='a';
ff[2][0]='i';ff[2][1]='o';ff[2][2]='u';ff[2][3]='a';ff[2][4]='e';
ff[3][0]='o';ff[3][1]='u';ff[3][2]='a';ff[3][3]='e';ff[3][4]='i';
ff[4][0]='u';ff[4][1]='a';ff[4][2]='e';ff[4][3]='i';ff[4][4]='o';
while(cin>>k){
int c=cmp(k),flag=1;
int v=k/c;
if(c<5||v<5){
cout<<"-1"<<endl;continue;
}//不能被分成长和宽小于5
for(i=0,w=0;i<v;i++,w++){
if(w==5)w=0;
for(j=0,h=0;j<c;j++,h++){
if(h==5)h=0;
cout<<ff[w][h];
}
}
cout<<endl;
}
}