日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 520C】DNA Alignment (快速幂,思维)

發(fā)布時(shí)間:2023/12/10 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 520C】DNA Alignment (快速幂,思维) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

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 function?h(s,?t)is defined as the number of positions in which the respective symbols of?s?and?t?are?the same. Function?h(s,?t)?can be used to define the function of Vasya distance?ρ(s,?t):

where??is obtained from string?s, by applying left circular shift?i?times. For example,

ρ("AGC",?"CGT")?=?

h("AGC",?"CGT")?+?h("AGC",?"GTC")?+?h("AGC",?"TCG")?+?

h("GCA",?"CGT")?+?h("GCA",?"GTC")?+?h("GCA",?"TCG")?+?

h("CAG",?"CGT")?+?h("CAG",?"GTC")?+?h("CAG",?"TCG")?=?

1?+?1?+?0?+?0?+?1?+?1?+?1?+?0?+?1?=?6

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 modulo?109?+?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.

Examples

Input

1 C

Output

1

Input

2 AG

Output

4

Input

3 TTT

Output

1

Note

Please note that if for two distinct strings?t1?and?t2?values?ρ(s,?t1)?и?ρ(s,?t2)are maximum among all possible?t, 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 strings?t?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ào)告:

? ? 直接看哪個(gè)字母出現(xiàn)的次數(shù)最多就行了,注意有可能很多字母出現(xiàn)的次數(shù)一樣多,所以掃兩遍就做完了。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; char s[MAX]; int bk[20]; ll mod = 1e9+7; ll qpow(ll a,ll k) {ll res = 1;while(k) {if(k&1) res = (res*a)%mod;k>>=1;a=(a*a)%mod; }return res; } int main() {ll n;cin>>n;cin>>(s+1);int len = strlen(s+1);for(int i = 1; i<=len; i++) {if(s[i] == 'A') bk[1]++;if(s[i] == 'C') bk[2]++;if(s[i] == 'G') bk[3]++;if(s[i] == 'T') bk[4]++;}int maxx = *max_element(bk+1,bk+5);ll cur = 0;for(int i = 1; i<=4; i++) {if(bk[i] == maxx) cur++;}printf("%lld\n",qpow(cur,n));return 0 ;}

?

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 520C】DNA Alignment (快速幂,思维)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美激情一区二区 | 日韩一区在线看 | 99精品热| 亚洲国产欧洲 | 新久草视频 | 91综合久久 | 疯狂做爰的爽文多肉小说王爷 | 麻豆精品视频免费观看 | 欧美日韩一区在线 | 久草免费资源 | 91成人国产 | 91禁外国网站 | 精品婷婷色一区二区三区蜜桃 | www.蜜臀av.com| 午夜激情在线观看 | 黄色永久免费网站 | 人人妻人人澡人人爽人人欧美一区 | 日韩精品网站 | 九色视频丨porny丨丝袜 | 91久久一区二区三区 | 午夜国产在线视频 | 国产91免费 | 久草热线| 成人欧美在线视频 | 99久久国产精 | 日韩av动漫 | 天天综合天天 | 三级麻豆| 免费在线观看日韩 | 国产做爰xxxⅹ高潮视频12p | 黄色片免费在线播放 | aaaa黄色片 | 北条麻妃在线一区二区 | 在线视频天堂 | 伊人午夜 | 国产美女免费视频 | 亚洲男女视频 | 亚洲欧美日韩在线看 | 欧美少妇一区二区三区 | 日韩视频 中文字幕 | 少妇又紧又色 | 在线国产福利 | 日本黄色电影网址 | 中国美女黄色 | 一级黄色免费视频 | 国产精品视频一区二区三区在3 | 一级特级黄色片 | 欧美中文字幕视频 | 成人福利免费视频 | 国产麻豆一区二区三区 | www狠狠干| 久久久午夜精品 | 日韩av免费 | 精品国产无码一区二区 | 国产只有精品 | 公交上高潮的丁芷晴 | 黄三级| 成人福利小视频 | 日本精品久久久久中文字幕 | 国产午夜免费 | 电影寂寞少女免费观看 | 青在线视频 | 男人在线天堂 | 污视频在线播放 | 国产鲁鲁视频在线观看特色 | 黑人精品xxx一区一二区 | 日韩影视一区二区三区 | 欧美乱大交xxxxx春色视频 | 日韩免费大片 | 欧美高清久久 | 国产99久久久国产精品成人免费 | 超碰66| 奶妈的诱惑 | 日本蜜桃视频 | 欧美色图亚洲激情 | 毛片基地站 | 国产麻豆精品久久一二三 | 免费观看h片 | 黄色a站| 性感美女一区二区三区 | 精品人妻一区二区三区免费 | 99爱这里只有精品 | 亚洲二区在线播放视频 | 天天舔日日操 | 精品少妇v888av | 性开放视频| 特大黑人巨交吊性xxxxhd | 黑人玩弄人妻一区二区三区 | 欧美亚洲一级片 | 成人国产网站 | 黄色高清片 | 国产精品 欧美 日韩 | 欧美麻豆| 精品久久久久久久久久久久久久 | 可以看av的网站 | 国产香蕉一区 | 男人用嘴添女人下身免费视频 | 手机看片日韩久久 | 亚洲图片视频小说 |