[PYTHON] ABC175

We participated in AtCorder Beginner Contest 175. It was ABC's 3 questions AC. I'm using Python3.

A problem

First, find the number of rains (R). This time, the number of consecutive rains (R) is calculated, so in the case of RSR, the case of answering 1 is processed. One exception is sufficient, as only 3 days of weather will be entered.

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    s=input()
    c = s.count("R")
    if c == 2 and s[1] == "S":
        c += -1
    print(c)

    
if __name__ == "__main__":
    main()

B problem

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    L = list(map(int,input().split()))
    ans = 0
    for i in L:
        for j in L:
            for k in L:
                if i < j and j < k and (i+j) > k and (i+k) > j and (j+k) >i:
                    ans +=1
    print(ans)

    
if __name__ == "__main__":
    main()

C problem

Takahashi's behavior patterns can be broadly divided into two. ・ Even if you act K times, you cannot reach 0 from X (as close as possible) ・ It reached 0 from X in less than K times, and returned to near 0 by reciprocating with the remaining number of times. The second pattern is divided according to whether the number of remaining times is even or odd.

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    X,K,D = map(int,input().split())
    x = abs(X)
    if K * D < x:
        ans = x - K * D
    else:
        shou = x // D
        nokori = K - shou
        
        if nokori % 2 == 0:
            ans = x % D    
        else:
            ans = abs((x % D) - D)
            
    print(ans)


    
if __name__ == "__main__":
    main()

Recommended Posts

ABC168
ABC164
ABC174
ABC175
ABC170
ABC182
ABC153
ABC146 Impressions
AtCoder ABC176
AtCoder ABC177
Beginner ABC154 (Python)
Beginner ABC156 (Python)
abc154 participation report
abc155 participation report
AtCoder ABC 174 Python
AtCoder ABC187 Python
AtCoder ABC188 Python
Beginner ABC155 (Python)
AtCoder ABC 175 Python
Looking back on ABC155
Atcoder ABC115 Past Exercises
Solve ABC169 in Python
ABC147 C --HonestOrUnkind2 [Python]