Codeforces Round #295 (Div. 2) C. DNA Alignment(数学)
来源:互联网 发布:轮播图原生js代码 编辑:程序博客网 时间:2024/06/06 19:32
题目:
http://codeforces.com/problemset/problem/520/C
题意:
长度为n 的字符串, 与只含有"ACGT"的n长度的字符串作比较,求出得到得数最大的字符串有几条.
思路:
求出字符串中重复次数最多的字母的个数x , 则答案为 ans = x ^ n.
AC.
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int mod = 1e9+7;char s[100005];int a[5];long long cal(long long x, int n){ long long ans = 1; while(n > 0) { if(n & 1) ans = (ans * x) % mod; x = (x * x) % mod; n >>= 1; } return ans;}int main(){//freopen("in", "r", stdin); int n; while(~scanf("%d", &n)) { scanf("%s", s); memset(a, 0, sizeof(a)); 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); int maxn = a[3]; long long cnt = 0; for(int i = 0; i < 4; ++i) { if(a[i] == maxn) cnt++; } long long ans = cal(cnt, n); printf("%I64d\n", ans); } return 0;}
0 0
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学)
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学水题)
- 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 ACM解题报告(math)
- 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 Round #320 (Div. 2) [Bayan Thanks-Round] C 数学
- 【组合数学】 Codeforces Round #295 (Div. 1) C - Pluses everywhere
- Codeforces Round #298 (Div. 2) C. Polycarpus' Dice(数学)
- Codeforces Round #284 (Div. 2) C. Crazy Town 数学
- Codeforces Round #246 (Div. 2)(C)数学,思维
- C语言中.h和.c文件解析
- 蓝桥杯 矩形区域的交和并 计算几何
- 20150310-Allegro增加电源层的方法
- blockingQueue队列
- Unity异步加载场景loading条 复制代码
- Codeforces Round #295 (Div. 2) C. DNA Alignment(数学)
- Linux芯片级移植与底层驱动(基于3.7.4内核)
- 维棠播放器
- CDN初探
- STL算法 ---------- Heap算法
- iOS 不使用UINavigationController实现Push动画
- GCD多线程
- HDU 1028 Ignatius and the Princess III
- 编写一个函数,将一个数字字符串转换成这个字符串对应的数字(包括正浮点数、负浮点数)