Description
Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining
the similarity of cyclic sequences.
Let's assume that strings s and t have the same length n, then the functionh(s, t) is defined as the number of positions in which the respective symbols ofs
and t arethe same. Functionh(s, t) can be used to define the function of Vasya distanceρ(s, t):


Vasya found a string s of length n on the Internet. Now he wants to count how many strings t there are such that the Vasya distance from the string s attains
maximum possible value. Formally speaking, t must satisfy the equation:.
Vasya could not try all possible strings to find an answer, so he needs your help. As the answer may be very large, count the number of such strings modulo109 + 7.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 105).
The second line of the input contains a single string of length n, consisting of characters "ACGT".
Output
Print a single number — the answer modulo 109 + 7.
Sample Input
1C
1
2AG
4
3TTT
1
Sample Output
Hint
Please note that if for two distinct strings t1 andt2 valuesρ(s, t1) иρ(s, t2) are maximum among all possiblet, then both strings must be taken into
account in the answer even if one of them can be obtained by a circular shift of another one.
In the first sample, there is ρ("C", "C") = 1, for the remaining stringst of length 1 the value ofρ(s, t) is 0.
In the second sample, ρ("AG", "AG") = ρ("AG", "GA") = ρ("AG", "AA") = ρ("AG", "GG") = 4.
In the third sample, ρ("TTT", "TTT") = 27
分析:这道题读了好久才弄明白是什么意思,实际上就是求出现最多的次数的字符,若出现次数最多的字母不唯一,那么相当于B串每一位我们都有不唯一的选择,
设我们有x种选择,那么最后构造出的B串种数就是ans^n,因此我们就可以得到最终答案:ans^n 取摸。
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
#define ll long long
const ll M=1000000007;
int n;
string input;
map<char,ll> a;
const string s="ATCG";
ll maxn=-1,cnt,ans=1;
int main()
{
cin>>n>>input;
for(int i=0;i<n;i++)
a[input[i]]++;
for(int i=0;i<4;i++)//找出出现次数最多的字符
if(a[s[i]]==maxn)
cnt++;
else if(a[s[i]]>maxn)
{
maxn=a[s[i]];
cnt=1;
}
while(n)
{
if(n&1)ans*=cnt;
ans%=M;
n>>=1;
cnt=cnt*cnt%M;}
cout<<ans<<endl;
return 0;
}