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 ...
随机推荐
- Applying the Kappa architecture in the telco industry
https://www.oreilly.com/ideas/applying-the-kappa-architecture-in-the-telco-industry Kappa architectu ...
- nginx+tomcat把带WWW域名自动跳转到不带www域名方法
nginx+tomcat把带WWW域名自动跳转到不带www域名方法在nginx.conf里面 include /etc/nginx/conf.d/*.conf;在应该server里增加: if ($h ...
- Linux解压文件到指定目录
Linux解压文件到指定目录 tar在Linux上是常用的打包.压缩.加压缩工具,他的参数很多,折里仅仅列举常用的压缩与解压缩参数 参数:-c :create 建立压缩档案的参数:-x : 解压缩压缩 ...
- 03: Memcached
目录: 1.1 Memcached简介与安装 1.2 python-memcached模块天生支持集群 1.3 Memcached基本操作 1.1 Memcached简介与安装返回顶部 1.Memca ...
- IDEA 插件-码云
插件安装 最新插件版本: 2018.3.1.(2019-01-10 发布)注意:码云 IDEA 插件已由 gitosc 更名为 gitee.新版插件 gitee 菜单已经和 git 菜单合并 通过「插 ...
- Python3基础 str while+iter+next 字符串的遍历
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 为 Android 8.0 添加开机启动脚本【转】
本文转载自:https://zhuanlan.zhihu.com/p/32868074 本人对于 SELinux for Android 理解不深,下文中的各文件及安全规则虽都是我所编写,但也是一边查 ...
- 完美解决vim在终端不能复制的问题
以前 用xshell,或者其他工具ssh到远程服务器,vim不能复制,搜索说是vim的 -xterm_clipboard没有开启. 今天发现,至少鼠标复制是不需要这个东东的! 在stackoverfl ...
- 【自动化】基于Spark streaming的SQL服务实时自动化运维
设计背景 spark thriftserver目前线上有10个实例,以往通过监控端口存活的方式很不准确,当出故障时进程不退出情况很多,而手动去查看日志再重启处理服务这个过程很低效,故设计利用Spark ...
- 树莓派GPIO