Löse ABC158 A ~ C mit Python

Einführung

Ich habe vergessen und konnte nicht teilnehmen, also werde ich es lösen. Ich habe es mit Mitternachtsspannung gelöst + Ich habe es um Mitternacht geschrieben, sodass der Satz möglicherweise zusammengebrochen ist.

Ein Problem

Problem

** Gedanken ** Zählen Sie einfach A und B in S. Nur wenn alle A und B sind, sollte Nein gesetzt werden. .. Ich habe es mit str.count gezählt und wenn.

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

Denkweise Zählen Sie einfach, wie viele A + B-Paare es in N gibt. Die Anzahl der Paare von $ A + B * A $ allein beinhaltet nicht den Rest. Berechnen Sie also den Rest mit $ N% (A + B) $ und addieren Sie ihn. Wenn Sie darüber nachdenken, kann der Rest größer als A sein, also addieren Sie 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 ** Gedanken ** Ich habe es normal berechnet. Der Grund, warum 1WA herauskam, ist, dass der Stopp der for-Anweisung auf 1000 anstelle von 1001 gesetzt wurde. Aus diesem Grund konnte einer von ihnen den Fall mit 1000 nicht beantworten. Jeder sollte vorsichtig sein, wenn er für stoppt.

Wenn Sie es runden, ist 1009 * 0.10 ebenfalls 100, daher müssen Sie es auf 1010 setzen.

import math
a, b = map(int,input().split())
ans = []
for i in range(1010): #Ich habe hier 1000 gemacht
    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)

Zusammenfassung

Es stellt sich heraus, dass ein einfaches ABC auch um Mitternacht gelöst werden kann. Gute Nacht

Recommended Posts

Löse ABC163 A ~ C mit Python
Löse ABC168 A ~ C mit Python
Löse ABC162 A ~ C mit Python
Löse ABC167 A ~ C mit Python
Löse ABC158 A ~ C mit Python
Löse ABC166 A ~ D mit Python
Löse ABC036 A ~ C mit Python
Löse ABC037 A ~ C mit Python
Löse ABC175 A, B, C mit Python
[AtCoder] Löse ABC1 ~ 100 Ein Problem mit Python
Löse AtCoder ABC168 mit Python (A ~ D)
Löse AtCoder ABC166 mit Python
[AtCoder] Lösen Sie ein Problem von ABC101 ~ 169 mit Python
Fordern Sie AtCoder (ABC) 164 mit Python heraus! A ~ C Problem
ABC127 A, B, C Erklärung (Python)
ABC166 in Python A ~ C Problem
AtCoder ABC 114 C-755 mit Python3 gelöst
ABC128 A, B, C Kommentar (Python)
ABC126 A, B, C Erklärung (Python)
Löse den Atcoder ABC176 (A, B, C, E) in Python
[AtCoder Erklärung] Kontrollieren Sie ABC180 A, B, C Probleme mit Python!
[AtCoder Erklärung] Kontrollieren Sie ABC158 A, B, C Probleme mit Python!
[AtCoder Erklärung] Kontrollieren Sie ABC164 A, B, C Probleme mit Python!
[AtCoder Erklärung] Kontrollieren Sie ABC168 A, B, C Probleme mit Python!
Ich wollte ABC160 mit Python lösen
Löse ABC165 A, B, D mit Python
Ich wollte ABC172 mit Python lösen
Löse AtCoder 167 mit Python
Löse Mathe mit Python
Löse ABC169 mit Python
ABC147 C --HonestOrUnkind2 [Python]
Löse POJ 2386 mit Python
Ich wollte das ABC164 A ~ D-Problem mit Python lösen
Löse A ~ D des Yuki-Codierers 247 mit Python
[Erklärung zum AtCoder] Kontrollieren Sie die A-, B- und C-Probleme von ABC182 mit Python!
Lösen mit Ruby, Perl, Java und Python AtCoder ABC 047 C Regulärer Ausdruck
[AtCoder Erklärung] Kontrollieren Sie ABC184 A, B, C Probleme mit Python!
[Python] Löse Gleichungen mit Sympy
AtCoder ABC 177 Python (A ~ E)
AtCoder ABC 178 Python (A ~ E)
ABC129 A, B, C Kommentar
Löse ABC176 E in Python
ABC-Memorandum [ABC163 C --managementr] (Python)
Löse ABC175 D in Python
Machen Sie eine Lotterie mit Python
AtCoder ABC 182 Python (A ~ D)
Erstellen Sie ein Verzeichnis mit Python
Versuchen Sie, Python mit pybind11 in ein C ++ - Programm einzubetten
Machen Sie mit Python einen Haltepunkt auf der c-Ebene
[Erklärung zum AtCoder] Kontrollieren Sie die A-, B-, (C), D-Probleme von ABC165 mit Python!
[AtCoder-Erklärung] Kontrollieren Sie die A-, B-, C- und D-Probleme von ABC183 mit Python!
[Erklärung zum AtCoder] Kontrollieren Sie die A-, B-, C- und D-Probleme von ABC181 mit Python!
[Python] Was ist eine with-Anweisung?