【题目链接】:http://codeforces.com/contest/520/problem/C

【题意】



给你一个函数;

它的作用是评估两个字符串的相似程度;

评估的时候;

保持一个字符串不动,另外一个字符串比较n次->n为字符串的长度

但比较的n次是这样的:另外一个字符串比完一次之后会往左滑动一格,第一个字符串会跑到最后一个位置;

然后第一个字符串也按照上面的规则往左移动一个格子;然后再比较n次。

每次比较得到的相同的字符的个数的和就是这个函数的输出.

【题解】



贪心。

记录输入的字符串出现次数最多的字符;

最后结果全是那个字符是最优解;

但可能有多个出现次数最多的字符->设组成集合S;

则每个位置选那个集合里面任意一个元素都可以;

所以就是S的大小x它的n次方;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const char t[5] = { '8','A','C','G','T' };
const double pi = acos(-1.0);
const int N = 1e5+100;
const LL MOD = 1e9 + 7; int n;
char s[N];
map<char, int> dic; LL ksm(LL x, LL y)
{
if (y == 1)
return x;
LL temp = ksm(x, y >> 1);
temp = (temp*temp)%MOD;
if (y & 1) temp = (temp*x)%MOD;
return temp;
} int main()
{
//freopen("F:\\rush.txt", "r", stdin);
rei(n);
scanf("%s", s + 1);
rep1(i, 1, n)
dic[s[i]]++;
int ma = 0, cnt = 0;
rep1(i, 1, 4)
if (dic[t[i]] > ma)
{
ma = dic[t[i]];
cnt = 1;
}
else
if (dic[t[i]] == ma)
cnt++;
printf("%lld\n", ksm(cnt, n));
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}

【codeforces 520C】DNA Alignment的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. 2019-8-31-Developing-Universal-Windows-Apps-开发UWA应用-问答

    title author date CreateTime categories Developing Universal Windows Apps 开发UWA应用 问答 lindexi 2019-08 ...

  2. Nginx 函数解析之ngx_http_get_forwarded_addr_internal

    static ngx_int_t ngx_http_get_forwarded_addr_internal(ngx_http_request_t *r, ngx_addr_t *addr, u_cha ...

  3. tinkcmf视频上传大小限制

    /application/Common/Common/function.php 找到upload_max_filesize把后面的数值改成合适的大小(单位是KB)

  4. JavaScript的注意事项

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. [PHPCMS V9二次开发]自定义字段模型-添加字段类型

    步骤/方法 打开phpcms\modules\content\fields目录,复制文件夹downfiles,并改名为textgroups. 打开phpcms\modules\content\fiel ...

  6. 廖雪峰Python总结5

    1.错误,调试和测试 程序编写造成了bug(必须修复) 用户输入出错(通过检查用户输入) 异常:无法在程序运行过程中预测的.异常是必须被处理的,否则程序会因为各种问题终止并且退出 1.try: try ...

  7. malloc: *** error for object 0x10a291df8: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug

    malloc_error_break错误: .You'll find out what the object is when you break in the debugger. Just look ...

  8. 类似淘宝五星点评 ,Jquery实现代码

    <!--默认五星,根据鼠标点击判断--> <!DOCTYPE html><html lang="en"><head> <met ...

  9. SPSS和Mplus如何做非线性中介调节效应分析?如倒U形曲线

    SPSS和Mplus如何做非线性中介调节效应分析?如倒U形曲线 传统的线性回归模型用的比较多,但有时候变量之间的关系更符合非线性关系,此时使用非线性模型其拟合度会更好,模型预测效果更佳.在非线性关系中 ...

  10. java通过实体类组装报文

    条件: 1.实体类字段名 首字母小写(java规范),再通过报文的需求,填充的时候做对应修改即可(正常报文首字母是大写的)! 2.假如xml标签首字母是小写,那么实体类就给大写,首字母是大写,那么实体 ...