首页 > 其他 > 详细

CF804B Minimum number of steps

时间:2019-10-03 16:12:47      阅读:64      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/guangheli/p/11619860.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!