Simple Palindrome
题目描述
Narek has to spend 2 hours with some 2-year-old kids at the kindergarten. He wants to teach them competitive programming, and their first lesson is about palindromes.
Narek found out that the kids only know the vowels of the English alphabet (the letters a \mathtt{a} a , e \mathtt{e} e , i \mathtt{i} i , o \mathtt{o} o , and u \mathtt{u} u ), so Narek needs to make a string that consists of vowels only. After making the string, he’ll ask the kids to count the number of subsequences that are palindromes. Narek wants to keep it simple, so he’s looking for a string such that the amount of palindrome subsequences is minimal.
Help Narek find a string of length $ n $ , consisting of lowercase English vowels only (letters a \mathtt{a} a , e \mathtt{e} e , i \mathtt{i} i , o \mathtt{o} o , and u \mathtt{u} u ), which minimizes the amount of palindrome † ^{\dagger} † subsequences ‡ ^{\ddagger} ‡ in it.
† ^{\dagger} † A string is called a palindrome if it reads the same from left to right and from right to left.
‡ ^{\ddagger} ‡ String t t t is a subsequence of string s s s if t t t can be obtained from s s s by removing several (possibly, zero or all) characters from s s s and concatenating the remaining ones, without changing their order. For example, o d o c s \mathtt{odocs} odocs is a subsequence of c od ef o r c e s \texttt{c}{\color{red}{\texttt{od}}}\texttt{ef}{\color{red}{\texttt{o}}}\texttt{r}{\color{red}{\texttt{c}}}\texttt{e}{\color{red}{\texttt{s}}} codeforces .
输入格式
The first line of the input contains a single integer t t t ( 1 ≤ t ≤ 100 1\le t \le 100 1≤t≤100) — the number of test cases. Subsequently, the description of each test case follows.
The only line of each test case contains a single integer n n n ( 1 ≤ n ≤ 100 1 \le n \le 100 1≤n≤100 ) — the size of the string.
输出格式
For each test case, output any string of length n n n that satisfies the above conditions.
样例 #1
样例输入 #1
3
2
3
6
样例输出 #1
uo
iae
oeiiua
提示说明
In the first example, uo \texttt{uo} uo has only three palindrome subsequences: u \texttt{u} u , o \texttt{o} o , and the empty string. It can be shown that there is no better answer.
In the third example, oeiiua \texttt{oeiiua} oeiiua has only eight palindrome subsequences: o \texttt{o} o , e \texttt{e} e , i \texttt{i} i , i \texttt{i} i , u \texttt{u} u , a \texttt{a} a , ii \texttt{ii} ii , and the empty string. It can be shown that there is no better answer.
代码内容
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s="aeiou";
void solve()
{
ll n;
cin>>n;
ll x=n/5,y=n%5;
for(ll i=0;i<5;i++)
{
if(y) cout<<s[i],y--;
for(ll j=0;j<x;j++)
cout<<s[i];
}
cout<<endl;
}
int main()
{
ll t;
cin>>t;
while(t--) solve();
return 0;
}