This time it was ABC Sankaku. Since d is a character string problem, I skipped it and thought about E.
** Thoughts ** Pull with str and check with in
n = input()
if '7' in n:
print('Yes')
else:
print('No')
** 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)
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 ...
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