CodeForces 520C DNA Alignment
Question:
A piece of DNA (10 ^ 5 length) define the h function as the number of identical bases for two sequences p function is the sum of all possible h functions after moving the two DNA sequences respectively
Ideas:
According to the definition of the p function, we find that the p function is actually the comparison of each base and B Base in the series and then multiply by another n.
Therefore, the greedy structure of the B sequence is that each time A base is added, it must be the most frequently used base in the sequence.
The final answer is the N power of the most frequently occurring base types in sequence.
Code:
#include
#include
#include
#include
#include#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long LL;#define N 100010#define mod 1000000007int n;char s[N];int f[10];template
inline void RD(T &ret){ char c; ret = 0; while ((c = getchar()) < '0' || c > '9'); while (c >= '0' && c <= '9') ret = ret * 10 + (c - '0'), c = getchar();}LL quickpow(LL m , int n){ LL ans = 1; while(n) { if(n&1) ans = (ans * m) % mod; n = n >> 1; m = (m * m) % mod; } return ans;}int main(){ RD(n); scanf("%s",s); for(int i=0;i