CodeForces 520C DNA Alignment

Source: Internet
Author: User

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
             
              

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.