CodeForces 520C 水构造

//520C - DNA Alignment

 1 #include "iostream"
 2 #include "cstdio"
 3 using namespace std;
 4 const __int64 mod = 1e9 + 7;
 5 int n;
 6 char str[100010];
 7 int Count[5];
 8
 9 __int64 bin(__int64 n, __int64 k)
10 {
11     __int64 res = 1;
12     while(k) {
13         if(k & 1)
14             res *= n, res %= mod;
15         n *= n;
16         n %= mod;
17         k >>= 1;
18     }
19     return res;
20 }
21
22 int main()
23 {
24     int i;
25     scanf("%d%s", &n, str + 1);
26     for(i = 1; i <= n; ++i) {
27         switch(str[i]) {
28         case ‘A‘:
29             ++Count[1];
30             break;
31         case ‘C‘:
32             ++Count[2];
33             break;
34         case ‘G‘:
35             ++Count[3];
36             break;
37         case ‘T‘:
38             ++Count[4];
39         }
40     }
41     int Max = max(max(Count[1], Count[2]), max(Count[3], Count[4]));
42     int Choice = 0;
43     for(i = 1; i <= 4; ++i)
44         if(Max == Count[i])
45             ++Choice;
46     printf("%I64d\n", bin(Choice, n));
47 }
时间: 2024-08-06 11:34:06

CodeForces 520C 水构造的相关文章

CodeForces 26C Parquet 构造题

题目链接:点击打开链接 #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <math.h> #include <set> using namespace std; #define N 105 int n,m,a,b,c; char s[N][N]; set<char>myset; bool inm

CodeForces 520C DNA Alignment

题意: 一段DNA序列(10^5长度)  定义h函数为两序列相同碱基个数  p函数为分别移动两个DNA序列后所有可能的h函数之和  问使p最大的序列有多少个 思路: 根据p函数的定义  我们发现p这个函数其实就是A序列每个碱基和B序列每个碱基比较再乘一个n 因此可以贪心构造B序列  即每次新加一个碱基必定是A序列中出现次数最多的碱基 那么最后的答案就是A序列中出现次数最多的碱基种类数的n次方 代码: #include<cstdio> #include<iostream> #incl

codeforces #306D Polygon 构造

题目大意:给定n,要求构造一个凸n边形,使得每个内角都相同,每条边长度都不同 膜拜题解 其实我一开始想的是构造一个正n边形然后把每条边微移一下--不过似乎不是很好写的样子= = #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 110 #define PI 3.14159265358979

Pearls in a Row CodeForces 620C 水题

题目:http://codeforces.com/problemset/problem/620/C 文章末有一些测试数据仅供参考 题目大意:就是给你一个数字串,然后将分成几个部分,要求每个部分中必须有一对儿相等的数字,每个数字都属于某个部分,输出划分的部分数量以及对应区间. 很简单一道题,输入的数据都不用存的,输入一个检测一个就好了,用map打标记,用容器存一下要输出的区间端点值,最后挨个儿输出就好了 代码如下: #include<iostream> #include<map> #

Codeforces 1030D 【构造】

LINK 题目大意:给你n,m,k,让你在一个n*m的点阵里构造出一个面积为\(\frac{n*m}{k}\)的三角形 思路 首先要有一个结论是整点三角形的面积分母最多为2,然后就可以判断不存在的情况了 接下来就直接进行构造就可以了 #include<bits/stdc++.h> using namespace std; #define LL long long #define IL inline #define fu(a,b,c) for(LL a=b;a<=c;++a) #defin

New Roads CodeForces - 746G (树,构造)

大意:构造n结点树, 高度$i$的结点有$a_i$个, 且叶子有k个. 先确定主链, 然后贪心放其余节点. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include &l

Codeforces 734C [水][暴力][贪心]

题意: 要生产n个物品,每个花费时间为x. 有两种魔法,每种最多使用1个. 其中第一种魔法可以使每个物品生产的花费时间变为ai,相应的花费是bi;第二种魔法可以减少ci个物品,相应的花费是di,并且保证对于i<j ci<=cj 且 di<=dj; #include<bits/stdc++.h> using namespace std; long long b[200050],c[200050],d[200050]; pair<long long ,long long&g

Lottery - CodeForces 589I(水)

题目大意:有N个球K个人,现在要给这N个球涂上K种颜色,要求使抽到球的不同颜色的概率一致(N确保是K的倍数),求出来至少要给多少个球重新涂上颜色. 分析:先求出来所有球的每种颜色的个数,然后不到平均数的加上距离平均数的个数即可. 代码如下: ---------------------------------------------------------------------------------------------------------------------------------

codeforces 589a(构造的字符串后,最后要加终止符,,,)

模拟注意细节,没什么好说的#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <iostream> #include <map> #include <queue> #include <stack> #include <cmath> //#pragma comment(linker,