Solve ABC175 A, B, C in Python

Introduction

I feel like saying it every time, but it's been a long time. Succeeded in preventing 4 consecutive colds.

Rainy Season 1WA

** Thoughts ** Counts how many Rs are in a row.


s = input()

if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)

Since the if statement is processed from the top, it will be processed in order, so be careful of the order. I was WA with this.

Making Triangle ** Thoughts ** I just did the existence condition of the triangle, but it took time to misread the problem sentence. Search all for small $ N $.

n = int(input())
n = int(input())
l = list(map(int,input().split()))

ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            else:
                ver = [l[i],l[j],l[k]] #3 side length
                ver.sort()
                if ver[0] + ver[1] > ver[2]:
                    ans += 1

print(ans)

Walking Takahashi ** Thoughts **

-If $ X $ is positive and $ X-K * D $ is also positive, then $ X-K * D $ has the closest absolute value.

-SimilarlyXIs negative,X+K*DIf is also positive, the absolute value is the closest|X+K*D|Will be.

――Imagine a case where neither of the above is true. Let $ dis $ be the smallest positive number that can be moved within $ K $ times, and $ dis'$ be the smallest negative number that can be reached within $ K $ times. If you arrive at $ dis $ at the $ T (T \ leq K) $ th time, --If T is an even number, then $ dis → dis'→ \ dots dis $ --If T is odd, then $ dis → dis'→ \ dots dis'$

x, k, d = map(int,input().split())

if x - k * d >= 0:
    print(x - k * d)
elif x + k * d <= 0:
    print(abs(x + k * d))
else:
    dis = x % d
    dis_p = d - dis
    t = k - x // d

    if t % 2 == 0:
        print(dis)
    else:
        print(dis_p)

Summary

The guideline of D was correct, but it was moss in the implementation. See you again, good night.

Recommended Posts

Solve ABC175 A, B, C in Python
Solve ABC036 A ~ C in Python
Solve ABC037 A ~ C in Python
Solve Atcoder ABC176 (A, B, C, E) in Python
Solve ABC165 A, B, D in Python
Solve ABC163 A ~ C with Python
ABC127 A, B, C Explanation (python)
ABC166 in Python A ~ C problem
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
ABC128 A, B, C commentary (python)
Solve ABC158 A ~ C with Python
ABC126 A, B, C Explanation (python)
Solve ABC169 in Python
ABC129 A, B, C commentary
Solve ABC176 E in Python
Solve ABC175 D in Python
Solve ABC166 A ~ D with Python
Solve Atcoder ABC169 A-D in Python
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
[AtCoder explanation] Control ABC158 A, B, C problems with Python!
[AtCoder explanation] Control ABC164 A, B, C problems with Python!
[AtCoder explanation] Control ABC168 A, B, C problems with Python!
ABC 157 D --Solve Friend Suggestions in Python!
Algorithm in Python (ABC 146 C Binary Search
python> keyword arguments> hoge (** {'a': 1,'b': 2,'c': 3})
[AtCoder] Solve ABC1 ~ 100 A problem with Python
I wanted to solve ABC159 in Python
Solve AtCoder ABC168 with python (A ~ D)
Solve ABC168D in Python
Solve ABC167-D in Python
Solve ABC146-C in Python
Next Python in C
Solve ABC098-C in Python
Solve ABC159-D in Python
C API in Python 3
ABC147 C --HonestOrUnkind2 [Python]
Python3> round (a --b, 7)
Solve ABC160-E in Python
Call a Python script from Embedded Python in C ++ / C ++
I tried adding a Python3 module in C
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
[AtCoder explanation] Control the A, B, C problems of ABC182 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC186 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC185 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC187 with Python!
What happens if you do "import A, B as C" in Python?
[AtCoder explanation] Control the A, B, C problems of ABC184 with Python!
Extend python in C ++ (Boost.NumPy)
AtCoder ABC 177 Python (A ~ E)
Take a screenshot in Python
Solve AtCoder ABC166 with python
Try to make a Python module in C language
Create a function in Python
Create a dictionary in Python
ABC163 C problem with python3
AtCoder ABC 178 Python (A ~ E)
Atcoder ABC164 A-C in Python
[AtCoder explanation] Control the A, B, (C), D problems of ABC165 with Python!