Solve ABC158 A ~ C with Python

Introduction

I forgot and couldn't participate, so I'll solve it. I solved it with midnight tension + I wrote it at midnight, so the sentence may have collapsed.

A problem

Problem

** Thoughts ** Just count A and B in S. Only when all are A and B, No should be set. .. I counted it with str.count and put it in if.

s = str(input())
station_a = s.count('A')
station_b = s.count('B')
if station_a != 3 and station_b != 3:
    print('Yes')
else:
    print('No')

B problem

Problem

Way of thinking Just count how many A + B pairs there are in N. The number of pairs of $ A + B * A $ alone does not include the remainder. So calculate the remainder with $ N% (A + B) $ and add it. If you think about it, the remainder may be larger than A, so add min (a, (n% (a + b))).

n, a, b =map(int,input().split())
p = n // (a + b)
ans = a * p + min(a,(n % (a + b)))
print(ans)

C problem

Problem 1WA ** Thoughts ** I calculated it normally. The reason why 1WA came out is that the stop of the for statement was set to 1000 instead of 1001. Because of this, one of them couldn't handle the case where the answer was 1000. Everyone should be careful about stop for for.

If you round it, 1009 * 0.10 will also be 100, so you have to make it 1010.

import math
a, b = map(int,input().split())
ans = []
for i in range(1010): #I made 1000 here
    price_8 = math.floor(i * 0.08)
    price_10 = math.floor(i * 0.1)
    if price_8 == a and price_10 == b:
        ans.append(i)

if len(ans) != 0:
    print(min(ans))
else:
    print(-1)

Summary

It turns out that a simple ABC can be solved even at midnight. good night

Recommended Posts

Solve ABC163 A ~ C with Python
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
Solve ABC158 A ~ C with Python
Solve ABC166 A ~ D with Python
Solve ABC036 A ~ C in Python
Solve ABC037 A ~ C in Python
Solve ABC175 A, B, C in Python
[AtCoder] Solve ABC1 ~ 100 A problem with Python
Solve AtCoder ABC168 with python (A ~ D)
Solve AtCoder ABC166 with python
ABC163 C problem with python3
ABC188 C problem with python3
Solve AtCoder ABC 186 with Python
ABC187 C problem with python
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
ABC127 A, B, C Explanation (python)
ABC166 in Python A ~ C problem
Solved AtCoder ABC 114 C-755 with Python3
ABC128 A, B, C commentary (python)
ABC126 A, B, C Explanation (python)
Solve Atcoder ABC176 (A, B, C, E) 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!
I wanted to solve ABC160 with Python
Solve ABC165 A, B, D in Python
I wanted to solve ABC172 with Python
Solve AtCoder 167 with python
Solve Sudoku with Python
Solve ABC169 in Python
ABC147 C --HonestOrUnkind2 [Python]
Solve POJ 2386 with python
I wanted to solve the ABC164 A ~ D problem with Python
Solve A ~ D of yuki coder 247 with python
[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!
Solve with Ruby, Perl, Java and Python AtCoder ABC 047 C Regular Expression
[AtCoder explanation] Control the A, B, C problems of ABC187 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC184 with Python!
[Python] Solve equations with sympy
AtCoder ABC 177 Python (A ~ E)
AtCoder ABC 178 Python (A ~ E)
ABC129 A, B, C commentary
Solve ABC176 E in Python
ABC memorandum [ABC163 C --managementr] (Python)
Solve ABC175 D in Python
Make a fortune with Python
AtCoder ABC 182 Python (A ~ D)
Create a directory with python
Try embedding Python in a C ++ program with pybind11
Make a breakpoint on the c layer with python
[AtCoder explanation] Control the A, B, (C), D problems of ABC165 with Python!
[AtCoder explanation] Control the A, B, C, D problems of ABC183 with Python!
[AtCoder explanation] Control the A, B, C, D problems of ABC181 with Python!
[Python] What is a with statement?