Solve ABC162 A ~ C with Python

Introduction

This time it was ABC Sankaku. Since d is a character string problem, I skipped it and thought about E.

A problem

Problem

** Thoughts ** Pull with str and check with in

n = input()
if '7' in n:
    print('Yes')
else:
    print('No')

B problem

Problem

** Thoughts ** Just fizzbuzz normally

n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

C problem

Problem 1TLE

** Thoughts ** Hate. It's a loop of $ 200 ^ 3 $ at most, so I tried to search all, but I did TLE. python's math.gcd seems to be slow. Since I did TLE, I passed it with pypy without using math.gcd. This 20 minutes is a waste.

k = int(input())

ans = 0
def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

for i in range(1,k+1):
    for j in range(1,k+1):
        for s in range(1,k+1):
            ans += gcd(gcd(i,j),s)

print(ans)

If you know that math can be used with pypy ...

Summary

It's hard. Excuse me, I couldn't check if math can be used with pypy because the server is heavy. I'm bad because I haven't created a pypy environment even locally. Various sad. 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 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 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
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
[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)
ABC129 A, B, C commentary
Solve ABC176 E in Python
ABC memorandum [ABC163 C --managementr] (Python)
AtCoder ABC 176 Python (A ~ E)
Solve ABC175 D in Python
Make a fortune with Python
AtCoder ABC 182 Python (A ~ D)
Create a directory with python
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?
ABC memorandum [ABC159 C --Maximum Volume] (Python)
Embed a Python interpreter into a C ++ app with pybind11 + cmake
Operate a receipt printer with python
A python graphing manual with Matplotlib.
Call C from Python with DragonFFI