Official

B - PASTal Code Editorial by tatyam


o が (先頭を \(0\) 文字目として) \(S\) の何文字目にあるかを探索し、あればその答えを \(x\) として \(\frac{x+3}{4}\) を、なければ none を出力すれば良いです。

回答例 (C++)

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string S;
    cin >> S;
    auto p = find(S.begin(), S.end(), 'o');
    if(p == S.end()) puts("none");
    else cout << (p - S.begin() + 3) / 4 << endl;
}

回答例 (Python)

x = input().find('o')
if x == -1:
    print("none")
else:
    print((x + 3) // 4)

posted:
last update: