Codeforces Round_(Div.2)C-DNA Alignment——法則

3126 ワード

回転http://blog.csdn.net/codebattle/article/details/44022103
15 ms 108 KB
#include<bits/stdc++.h>
#define ll long long
const int maxn=100005;
const int mod=1e9+7;
using namespace std;
int n;
char s[maxn];
int a[4];
ll pow_mod(ll k){
    ll ret=1;
    while(n){
        if(n&1) ret=(ll)ret*k%mod;
        k=k*k%mod;
        n>>=1;
    }
    return ret;
}
int main()
{
//#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
//#endif // ONLINE_JUDGE
    scanf("%d",&n);
    scanf("%s",s);
    ll k=1;
    for(int i=0;i<n;++i){
        if(s[i]=='A') a[0]++;
        if(s[i]=='C') a[1]++;
        if(s[i]=='G') a[2]++;
        if(s[i]=='T') a[3]++;
    }
    sort(a,a+4);
    for(int i=2;i>=0;--i){
        if(a[i]==a[3]) k++;
    }
    printf("%I64d
"
,pow_mod(k)); return 0; }