Codeforces Round #613 (Div. 2) A. Mezo Playing Zoma

1285A - Mezo Playing Zoma

思路:记L的数目为a,R的数目b 最后停在0右边最远到b 最后停在0左边最远到-a 再加上0这点 故最后停下的不同位置有a+b+1个 

官方:

注意:其实a+b就等于n,根本都不需要统计L、R各有几个

#include<bits/stdc++.h>
#define ll long long
using namespace std;


int main(){
    int n;
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        char c=getchar();
        if(c=='L')l++;
        else r++;
    }
    cout<<l+r+1;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/wyh447154317/p/12180869.html