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

结论只猜对了一半。

首先,如果只有一个元素结果肯定是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. Excel导出插件-VSTO

    前言 一个游戏通常需要10多个Excel表格或者更多来配置,一般会通过导出csv格式读取配置. 本文提供导出Excel直接生成c#文件,对应数据直接生成结构体和数组,方便开发排错和简化重复写每个表格的 ...

  2. HTTP 超文本协议

    转载 :http://mp.weixin.qq.com/s/3d3zhksViX2NTuIssiYGJg

  3. PHP读取sphinx 搜索返回结果完整实战实例

    PHP读取sphinx 搜索返回结果完整实战实例 网上搜索N久都没有一个正在读取返回sphinx结果的实例,都是到了matches那里就直接var_dump或者print_r了,没有读取到字段的例子, ...

  4. 解决secureCRT 数据库里没有找到防火墙 '无' 此会话降尝试不通过防火墙进行连接。

    解决secureCRT 数据库里没有找到防火墙 '无' 此会话降尝试不通过防火墙进行连接.的方法 中文版的CRT由于汉化的问题(把null翻译成无了),导致每次打开都会有个防火墙的错误提示:数据库里没 ...

  5. java copy 文件夹

    import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io ...

  6. Ubuntu去掉命令行前用户名和主机名方法

    Ubuntu去掉命令行前用户名和主机名方法 $ vi ~/.bashrc 按a或i进入编辑模式 PS1='${debian_chroot:+(debian_chroot)}\w\$ ' 默认为 PS1 ...

  7. sql server deadlock跟踪的四种方法

    最近写程序常会遇到deadlock victim,每次一脸懵逼.研究了下怎么跟踪,写下来记录下. 建测试数据 CREATE DATABASE testdb; GO USE testdb; CREATE ...

  8. Python Web学习笔记之SOCK_STREAM和SOCK_DGRAM

    SOCK_STREAM 数据流 一般是tcp/ip协议的编程 有保障的(即能保证数据正确传送到对方)面向连接的SOCKET,多用于资料(如文件)传送 SOCK_DGRAM 数据包 udp协议网络编程 ...

  9. bootstrap的carousel图片轮播

    整个轮播是放在一个div .carousel和.slide的div中的, 包括3个部分: 1. 第一个部分indicator位于下方的指示器部分. 结构是一个ol和li, ol的类是carousel- ...

  10. 如何在一台主机上管理自己的多个git repository

    在使用git时,通常是直接ssh-keygen生成默认秘钥.然后将共钥添加到远程仓库,就可以访问了. 但是,当我们有多个repository时,这种方式就不适用了,因为一个秘钥只能关联一个远程仓库. ...