1
4

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 5 years have passed since last update.

東大 創造情報学 院試 2017 プログラミング

Last updated at Posted at 2018-05-13

東大創造情報解答

(合っている保証なし)
USBのデータはこのファイルと同階層にあることを仮定しています.

1

2nm^2

2

txt_path = "./mat1.txt"
MAT1 = []
with open(txt_path) as f:
    mat = f.read()
    mat = mat.split(".")[0]
    mat1 = mat.split(",")
    print(len(mat1))
    print(len(mat1[0].split()))
    
    for i in mat1:
        MAT1.append(i.split())
print(MAT1)        
3
4
[['0', '1', '2', '3'], ['4', '5', '6', '7'], ['8', '9', '10', '11']]

3

txt_path1 = "./mat2.txt"
MAT2 = []
with open(txt_path1) as f:
    mat = f.read()
    mat = mat.split(".")[0]
    mat1 = mat.split(",")    
    for i in mat1:
        MAT2.append(i.split())
print(MAT1)
print(MAT2)

d = 0

m =[]

for i in range(len(MAT1)):
    a = []
    for j in range(len(MAT2)):
        d = 0
        for k in range(len(MAT1[i])):
            d += float(MAT1[i][k])*float(MAT2[k][j])
        a.append(d)
    m.append(a)
    
print(m)

trace = 0

for i in range(min(len(m),len(m[0]))):
    trace += float(m[i][i])
    
print("トレースは" + str(trace))
[['0', '1', '2', '3'], ['4', '5', '6', '7'], ['8', '9', '10', '11']]
[['1', '2', '3', '4'], ['5', '6', '7', '8'], ['9', '10', '11', '12'], ['13', '14', '15', '16']]
[[62.0, 68.0, 74.0, 80.0], [174.0, 196.0, 218.0, 240.0], [286.0, 324.0, 362.0, 400.0]]
トレースは620.0

4

まずs > m*nの場合は何も変わらない.

プログラムの順番的にmat1の行をキャッシュに格納できたら良さそう。
つまりn <= s で場合分けを考える.

m = 3
n = 4
s =5
if s >= m*n:
    print(n*(m**2))
if s < m*n:
    if s >= n:
        print(n*(m**2))
36

わからん、ギブ。 どうもキャッシュブロッキングという手法らしい。

誰か教えて

5

1:u, 2:s, 3:v. 4:s, 5:w, 6:s

6

1
4
1

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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?