CF804B Minimum number of steps

Posted guangheli

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF804B Minimum number of steps相关的知识,希望对你有一定的参考价值。

code: 

#include <bits/stdc++.h> 
#define N 2000000 
#define ll long long  
#define mod 1000000007 
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std; 
char S[N]; 
int main() 

    // setIO("input");        
    int i,j,n; 
    ll ans=0,pre=0;    
    scanf("%s",S+1);    
    n=strlen(S+1);      
    for(i=n;i>=1;--i) 
    
        if(S[i]==‘b‘) 
        
            ++pre; 
         
        else 
        
            ans=(ans+pre)%mod;  
            pre=2ll*pre%mod;       
        
    
    printf("%lld\n",ans); 
    return 0; 

  

以上是关于CF804B Minimum number of steps的主要内容,如果未能解决你的问题,请参考以下文章

codeforce 804B Minimum number of steps

LeetCode 452. Minimum Number of Arrows to Burst Balloons

[LeetCode] 1419. Minimum Number of Frogs Croaking

LC 871. Minimum Number of Refueling Stops

1689. Partitioning Into Minimum Number Of Deci-Binary Numbers

452. Minimum Number of Arrows to Burst Balloons