LoginSignup
1
2

More than 3 years have passed since last update.

A

N = int(input())
ans = 0
if N<2:
    ans = 0
else:
    ans = N - 1
print(ans)

B

N = input()
L = len(N)

for i in range(L):
    if int(N[-1]) == 0:
        N = N[0:L-i-1]

for i in range(int(len(N)/2)):
    if N[i] != N[len(N)-i-1]:
        print("No")
        exit()

print("Yes")

C

import math

R, X, Y = [int(a) for a in input().split()]
dis = math.sqrt(X**2 + Y**2)

if dis < R:
    print(2)
elif dis == R:
    print(1)
else:
    print(math.ceil(dis/R))

D

当日は時間切れで提出できず、残念。
後日じっくり考えたらできた。
itertoolsって初めて使ったけど、競プロで今後も役に立ちそう。

PythonではLTE。同じコードでPypyだと通りました

import itertools

S = []
strings = []
N = []
for i in range(3):
    S.append(input())
    N.append(list())
    for j in range(len(S[i])):
        strings.append(S[i][j])
        N[i].append(0)

str_set = set(strings)
str_list = list(str_set)

if len(str_set) > 10:
    print("UNSOLVABLE")
    exit()

for v in itertools.permutations(range(10), len(str_set)):
    if v[str_list.index(S[0][0])] == 0 or  v[str_list.index(S[1][0])] == 0 or  v[str_list.index(S[2][0])] == 0:
        continue
    N123 = [0, 0, 0]
    for i in range(3):
        num = ""
        for j in range(len(S[i])):
            num += str(v[str_list.index(S[i][j])])
        N123[i] = int(num)
    if (N123[0]+N123[1] == N123[2]) and (N123[0] != 0)and (N123[1] != 0)and (N123[2] != 0):
        for x in N123:
            print(x)
        exit()

print("UNSOLVABLE")
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2