わかさぎのブログ

プログラミング、Atcoderの勉強とか

2022-11-06から1日間の記事一覧

AtCoder Beginner Contest 275 C - Counting Squares

s=[] for i in range(9): tmp=list(input()) s.append(tmp) def nagasa(r1,r2): res=(r1[0]-r2[0])**2+(r1[1]-r2[1])**2 ans=pow(res,0.5) return ans zahyou=[] for i in range(9): for j in range(9): if s[i][j]=="#": zahyou.append((i,j)) from itertoo…

AtCoder Beginner Contest 276 C - Previous Permutation

N=int(input()) p=list(map(int,input().split())) def prev_permutation(a: list, l: int = 0, r: int = None) -> bool: if r is None: r = len(a) - 1 for i in range(r - 1, l - 1, -1): if a[i] > a[i + 1]: for j in range(r, i, -1): if a[i] > a[j]: …

AtCoder Beginner Contest 276 B - Adjacency List

N,M=map(int,input().split()) ab=[] for i in range(M): tmp=list(map(int,input().split())) ab.append(tmp) ab.insert(0,[0,0]) data=[[] for i in range(N+1)] for i in range(1,M+1): l=ab[i][0] r=ab[i][1] data[l].append(r) data[r].append(l) del d…

AtCoder Beginner Contest 276 A - Rightmost

S=list(input()) count=-1 for i,j in enumerate(S): if j=="a": count=i+1 print(count)

AtCoder Beginner Contest 276 D - Divide by 2 or 3

提出コード N=int(input()) a=list(map(int,input().split())) from functools import reduce import math def my_gcd(*numbers): return reduce(math.gcd, numbers) gcd=my_gcd(*a) a=[i/gcd for i in a] def prime_factorize(n): a = [] while n % 2 == 0:…