0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ITP1個人的に難しかった問題解説

Last updated at Posted at 2022-08-23

基本的に1問1動画で難しいと感じた動画を解説にアップしています。

ITP-1-6-b:足りないトランプを出力する問題

qiita.rb
N=int(input())
souts=["S","H","C","D"]
cards=[]

for i in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))
    elif s=="H":
        cards.append(13+int(n))
    elif s=="C":
        cards.append(26+int(n))
    elif s=="D":
        cards.append(39+int(n))
for j in range(1,53):
    if j not in cards:
        print(souts[(j-1)//13],(j-1)%13+1)

ITP1-7-d:行列の積の問題

シンプルに見えて3重ループが必要な問題。

qiita.rb
n,m,l=map(int,input().split())
A=[]
for i in range(n):
    #A=list(map(int,input().split()))
    A.append(list(map(int,input().split())))
B=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    row=[]
    for j in range(l):
        c=0
        for k in range(m):
            c+=A[i][k]*B[k][j]
        row.append(c)
        
    print(*row)  

他にもいろいろ解説あげていこう。
アイパッドでマークアップ使うと直接ページに書き込めるのが便利。
本当はPythonファイルで打った方がいいんだろうけど右手しか使えんからなあ;;

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?