Codeforces Round #295 (Div. 2)-C. DNA Alignment
来源:互联网 发布:armour是什么牌子 淘宝 编辑:程序博客网 时间:2024/06/05 13:28
原题链接
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):
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.
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".
Print a single number — the answer modulo 109 + 7.
1C
1
2AG
4
3TTT
1
#include <bits/stdc++.h>#define maxn 100005#define MOD 1000000007using namespace std;typedef long long ll;char str[maxn];int d[30];int main(){//freopen("in.txt", "r", stdin);int n;scanf("%d%s", &n, str);for(int i = 0; str[i]; i++){d[str[i]-'A']++;}ll maxs = 0, cnt = 0; for(int i = 0; i < 30; i++){if(d[i] > maxs){maxs = d[i];cnt = 1;}else if(d[i] && d[i] == maxs){cnt++;}} ll ans = 1;while(n--){(ans *= cnt) %= MOD;}printf("%I64d\n", ans);return 0;}
- C. DNA Alignment 数学公式推导 Codeforces Round #295 (Div. 2)
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学)
- Codeforces Round #295 (Div. 2) C. DNA Alignment
- Codeforces Round #295 (Div. 2)-C. DNA Alignment
- Codeforces Round #295 (Div. 2) C. DNA Alignment ACM解题报告(math)
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学水题)
- Codeforces Round #295 (Div. 2)C - DNA Alignment——规律
- C. DNA Alignment(Codeforces Round #295(div2))
- Codeforces Round #295 C. DNA Alignment
- #295 (div.2) C.DNA Alignment
- Codeforces #295(Div 2) A Pangram、B Two Buttons、C DNA Alignment
- CodeForces 520C DNA Alignment
- CodeForces 520C DNA Alignment
- 【Codeforces】 CF 520C DNA Alignment
- Codeforces 520C. DNA Alignment 找规律
- Codeforces Round #423 (Div. 2) E. DNA Evolution(树状数组)
- 【codeforces】Codeforces Round #370 (Div. 2) C
- 520C DNA Alignment
- 死锁产生的原因及四个必要条件
- 赛意递归
- Android中Context的使用
- c++:algorithm-find
- 配置编译安装内核
- Codeforces Round #295 (Div. 2)-C. DNA Alignment
- cmd——窗口标题及字体颜色、背景颜色设置
- 配置tomcat环境变量
- Java实现几种常见排序方法
- 单片机的动态内存管理-一以链表为例
- 使用JDBC出现NoClassDefFoundError异常的解决方法
- JAVA从菜鸟【入门】到新手【实习】一一Python小项目(Anaconda2)2,7X
- TYVJ 1077 有理逼近
- 洛谷P1941 Flappy Bird