0
0

More than 3 years have passed since last update.

ABC079をPythonで実装してみた。

Last updated at Posted at 2021-08-23

はじめに

本記事は、自身のAtCoderで実装能力を可視化するために備忘録として残していくためのものです。コメントにもあるように洗練された実装ではなく、実装が拙いのでご指摘下されば幸いです。

A - Good Integer

N=input()

n0 = N[0]
n1 = N[1]
n2 = N[2]
n3 = N[3]

if n0 == n1 and n0 == n2:
    print("Yes")
elif n1 == n2 and n1 == n3:
    print("Yes")
else:
    print("No")

B - Lucas Number

N = int(input())

L=[]

for i in range(N+1):
    if i == 0:
        L.append(2)
    elif i == 1:
        L.append(1)
    else:
        L.append(L[i-1] + L[i-2])

print(L[N])

C - Train Ticket

ABCD = input()
a = int(ABCD[0])
b = int(ABCD[1])
c = int(ABCD[2])
d = int(ABCD[3])

if a+b+c+d==7:
    print("%d+%d+%d+%d=7"%(a,b,c,d))
elif a+b+c-d==7:
    print("%d+%d+%d-%d=7"%(a,b,c,d))
elif a+b-c+d==7:
    print("%d+%d-%d+%d=7"%(a,b,c,d))
elif a+b-c-d==7:
    print("%d+%d-%d-%d=7"%(a,b,c,d))
elif a-b+c+d==7:
    print("%d-%d+%d+%d=7"%(a,b,c,d))
elif a-b+c-d==7:
    print("%d-%d+%d-%d=7"%(a,b,c,d))
elif a-b-c-d==7:
    print("%d-%d-%d-%d=7"%(a,b,c,d))
elif a-b-c+d==7:
    print("%d-%d-%d+%d=7"%(a,b,c,d))
0
0
2

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
0
0