Codeforces 520c
Train of thought: two strings, the first string does not move, you will find that each character of the second string will be a character pair with the first string, so when constructing it, the one with the most occurrences is chosen.
If the number of characters to assume the most occurrences of K, the first character has a k choice, the second has a k choice .... The nth character has a K-type choice,
RK (K,n);
#include <iostream>
using namespace Std;
#define M 1000000007;
int n;
Char a[100010];
int c[5];
//Two min fast exponentiation
Long long rk (int n, int k)
{
Long Long res = 1;
while (k) {
if (K & 1)
res *= N, res%= M;
n *= N;
n%= M;
k >>= 1;
}
return res;
}
int Main ()
{
int i;
Cin>>n>>a;
Iterate through a string to count the occurrences of each character
for (i = 1; I <= n; ++i)
{
if (a[i]== ' a ')
c[1]++;
else if (a[i]== ' G ')
c[2]++;
else if (a[i]== ' C ')
c[3]++;
Else
c[4]++;
}
Find out the number of occurrences of the most numerous occurrences of that character
int max = MAX (max (c[1], c[2]), Max (c[3], c[4]);
int m=0;
Get the type of the most numerous characters appearing
for (i = 1; I <= 4; ++i)
if (Max = = C[i])
m++;
Cout<<rk (M, N) <<endl;
}
A simple construct that you read the code to understand