题意:如题定义的函数,取最大值的数量有多少?

结论只猜对了一半。

首先,如果只有一个元素结果肯定是1.否则。s串中元素数量分别记为a,t,c,g。设另一个串t中数量为a',t',c',g'。那么,固定s串,移动t串时,增加的量为p=a*a'+t*t'+c*c'+g*g'。注意a'+t'+c'+g'是等于串长,那么减少a,t,c,g中最少的对应的那个a',t',c',g',增加到最大的那个上,p值是上升的。而且如果a==t那么a'和t'的数量互换是不影响p值的。因此结论是这种情况下,t串可随意 放出现最多的元素。结果是(一样多且最多的字母个数)^(t长度)

乱码:

//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
#include <list>
using namespace std;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon;
int num[];
lon mod=; lon pow(lon btn,lon n)
{
lon res=,ele=btn;
for(;n;)
{
if(n&)res*=ele;
ele*=ele;
res%=mod;
ele%=mod;
n/=;
}
return res;
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
int n;
cin>>n;
string str;
cin>>str;
num[]=count(str.begin(),str.end(),'A');
num[]=count(str.begin(),str.end(),'T');
num[]=count(str.begin(),str.end(),'C');
num[]=count(str.begin(),str.end(),'G');
int maxn=*max_element(num,num+);
int maxnum=count(num,num+,maxn);
if(maxnum==)
{
cout<<<<endl;
}
else
{
cout<<pow((lon)maxnum,(lon)str.size())<<endl;
}
return ;
}

codeforces 521a//DNA Alignment// Codeforces Round #295(Div. 1)的更多相关文章

  1. Codeforces Round #295 (Div. 2)C - DNA Alignment 数学题

    C. DNA Alignment time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. Codeforces Round #295 (Div. 2)

    水 A. Pangram /* 水题 */ #include <cstdio> #include <iostream> #include <algorithm> # ...

  3. 【记忆化搜索】Codeforces Round #295 (Div. 2) B - Two Buttons

    题意:给你一个数字n,有两种操作:减1或乘2,问最多经过几次操作能变成m: 随后发篇随笔普及下memset函数的初始化问题.自己也是涨了好多姿势. 代码 #include<iostream> ...

  4. Codeforces Round #295 (Div. 2)B - Two Buttons BFS

    B. Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. Codeforces Round #295 (Div. 2)A - Pangram 水题

    A. Pangram time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  6. Codeforces Round #295 (Div. 1) C. Pluses everywhere

    昨天ZZD大神邀请我做一道题,说这题很有趣啊. 哇,然后我被虐了. Orz ZZD 题目大意: 你有一个长度为n的'0-9'串,你要在其中加入k个'+'号,每种方案就会形成一个算式,算式算出来的值记做 ...

  7. Codeforces Round #295 (Div. 2)---B. Two Buttons( bfs步数搜索记忆 )

    B. Two Buttons time limit per test : 2 seconds memory limit per test :256 megabytes input :standard ...

  8. Codeforces Round #295 (Div. 2) B. Two Buttons

    B. Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  9. Codeforces Round #295 (Div. 2) B. Two Buttons 520B

    B. Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. 论文笔记:2018 PRCV 顶会顶刊墙展

    Global Gated Mixture of Second-order Pooling for Imporving Deep Convolutional Neural Network(2018 NI ...

  2. linux常用命令:tail 命令

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...

  3. linux常用命令:vmstat 命令

    vmstat 是Virtual Meomory Statistics(虚拟内存统计)的缩写,可对操作系统的虚拟内存.进程.CPU活动进行监控.他是对系统的整体 情况进行统计,不足之处是无法对某个进程进 ...

  4. yum hosts

    67.219.148.138 mirrorlist.centos.org202.38.97.230 ftp.sjtu.edu.cn202.121.199.235 mirrors.shu.edu.cn2 ...

  5. Java中字符转int

    Java中字符转int 方法一代码: //直接使用静态方法,不会产生多余的对象,但会抛出异常 //parseInt 方法都有两个参数, 第一个参数就是要转换的对象, 第二个参数是进制基数, 可以是 2 ...

  6. 05:ModelForm 数据验证 & 生成html & 数据库操作

    目录:Django其他篇 01:Django基础篇 02:Django进阶篇 03:Django数据库操作--->Model 04: Form 验证用户数据 & 生成html 05:Mo ...

  7. 安装mysql_cluster报错: Data::Dumper丢失

    步骤 安装包:mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64.tar.gz 下载解压到/usr/local/mysql mkdir /usr/local/m ...

  8. redis.windows.conf 参数说明

    1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以守护进程方式运行时,Redis默认会把pid写入/var/ru ...

  9. 20145105 《Java程序设计》第7周学习总结

    20145105 <Java程序设计>第7周学习总结 教材学习内容总结 第十三章 时间与日期 一.认识时间与日期 (一)时间的度量 格林威治标准时间 世界时 国际原子时 世界协调时 Uni ...

  10. 基于大规模语料的新词发现算法【转自matix67】

    最近需要对商品中的特有的词识别,因此需新词发现算法,matrix的这篇算法很好. 对中文资料进行自然语言处理时,我们会遇到很多其他语言不会有的困难,例如分词——汉语的词与词之间没有空格,那计算机怎么才 ...