codeforces 521a//DNA Alignment// Codeforces Round #295(Div. 1)
题意:如题定义的函数,取最大值的数量有多少?
结论只猜对了一半。
首先,如果只有一个元素结果肯定是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)的更多相关文章
- 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 ...
- Codeforces Round #295 (Div. 2)
水 A. Pangram /* 水题 */ #include <cstdio> #include <iostream> #include <algorithm> # ...
- 【记忆化搜索】Codeforces Round #295 (Div. 2) B - Two Buttons
题意:给你一个数字n,有两种操作:减1或乘2,问最多经过几次操作能变成m: 随后发篇随笔普及下memset函数的初始化问题.自己也是涨了好多姿势. 代码 #include<iostream> ...
- 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 ...
- 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 ...
- Codeforces Round #295 (Div. 1) C. Pluses everywhere
昨天ZZD大神邀请我做一道题,说这题很有趣啊. 哇,然后我被虐了. Orz ZZD 题目大意: 你有一个长度为n的'0-9'串,你要在其中加入k个'+'号,每种方案就会形成一个算式,算式算出来的值记做 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Python: itertools.compress()
定义: itertools.compress() 输入: iterable对象 相应的Boolean选择器序列 输出: iterable对象中对应选择器为True的元素 用途: 当需要用另外一个相关联 ...
- Linux基础命令---chown
chown 改变文件或者目录的所有者,或者所属的群组.如果只给出一个所有者(用户名或数字用户ID),则该用户将成为每个给定文件的所有者,并且文件的组不会被更改.如果所有者后面跟着冒号和组名(或数字组I ...
- oracle_存储过程小记
# 刷新会员标签函数 {color:red} fun_refresh_code{color} {noformat}CREATE OR REPLACE FUNCTION fun_refresh_code ...
- 03: KindEditor (HTML可视化编辑器)
目录: 1.1 kindEditor常用配置参数 1.2 kindEditor下载与文件说明 1.3 kindEditor实现上传图片.文件.及文件空间管理 1.1 kindEditor常用配置参数返 ...
- codevs 1423 骑士 - Tarjan - 动态规划
题目描述 Description Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英.他们劫富济贫,惩恶扬善,受到社会各界的赞扬. 最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵 ...
- Android Studio导入包
1.复制jar包,打开工程,以project形式打开,在libs下面粘贴: 2.右键jar包,add as library.
- ubuntu下转换flv格式为mp4格式
一.环境 ubuntu 16.04 二.安装工具 sudo apt install libav-tools 三.开始转换 avconv -i input.flv -codec copy output. ...
- Apache Kylin大数据分析平台的演进
转:http://mt.sohu.com/20160628/n456602429.shtml 我是来自Kyligence的李扬,是上海Kyligence的联合创始人兼CTO.今天我主要来和大家分享一下 ...
- [loss]Triphard loss优雅的写法
之前一直自己手写各种triphard,triplet损失函数, 写的比较暴力,然后今天一个学长给我在github上看了一个别人的triphard的写法,一开始没看懂,用的pytorch函数没怎么见过, ...
- 词云wordcloud类介绍&python制作词云图&词云图乱码问题等小坑
词云图,大家一定见过,大数据时代大家经常见,我们今天就来用python的第三方库wordcloud,来制作一个大数据词云图,同时会降到这个过程中遇到的各种坑, 举个例子,下面是我从自己的微信上抓的微信 ...