2023-06-17から1日間の記事一覧

atcoder ABC 306 D - Poisonous Full-Courseの間違い例と正解例

atcoder.jp・解説: Editorial - Toyota Programming Contest 2023#3(AtCoder Beginner Contest 306) ・反省点:食べたときと食べなかったときの遷移は別々にやるとWA。食べたときの遷移をして、食べたとき(dp[i+1][0],dp[i+1][1])と食べなかったとき(dp[…

atcoder ABC 306 C - Centersの解説

atcoder.jp・説明: cntというリストのa[i]番目(cnt[a[i]])を+1して2になったらa[i]を出力する。つまり前から数えてa[i]が2回出たタイミングでa[i]を出力する。 n=int(input()) a=list(map(int,input().split())) cnt=[0 for _ in range(n+1)] for i in rang…

c++のfor文をpythonで書く。

c++の for (int i=1;i<=n;i*=6) //何らかの処理というfor文をpythonで書くと i=1 while i<=n: #何らかの処理 i*=6 とかける。c++のほうがこの手のfor文は簡単にかける。・参考問題 atcoder.jp