東京大学 情報理工学系研究科 創造情報学専攻 2024年8月実施 プログラミング
Author
Description (English)
Answer the following questions by writing programs. The files needed for answering the questions are found in the USB flash drive. Store the programs in the USB flash drive before the examination ends.
In this problem, we represent matrices with
Format 1 Format 1 is a number sequence that arranges the entries of a matrix in the row-major order. In the row-major order, the entries in upper rows precede those in lower rows, and entries to the left precede to the right in a row. For example, the matrix
is represented as
1, -5, 0, 0, 3, 0in Format 1.
When a number sequence is stored in a file, the concatenated string of elements separated by commas is stored. For example, the file storing a sequence of the four elements,
2,5,-3,0
(1) Number sequences representing matrices in Format 1 are stored in files. For each of the following matrices, find the row such that the sum of the entries is the largest, and write down on the answer sheet its row number and the sum of its entries. If there are two or more such rows, answer about one of them.
(a) The matrix with 6 rows and 4 columns stored in data1a.txt.
(b) The matrix with 100 rows and 150 columns stored in data1b.txt.
Format 2 Let
be the entry of a matrix. We define Format 2 as the number sequence where the three integers and for all such that are arranged in the row-major order. For example, the matrix
is represented as
1, 1, 1, 1, 2, -5, 2, 2, 3in Format 2.
(2) Number sequences representing matrices in Format 2 are stored in files. For each of the following matrices, find the row such that the sum of the entries is the largest, and write down on the answer sheet its row number and the sum of its entries. If there are two or more such rows, answer about one of them.
(a) The matrix with 6 rows and 4 columns stored in data2a.txt.
(b) The matrix with 100 rows and 150 columns stored in data2b.txt.
(c) The matrix with data2c.txt.
Format 3 Let
be the number of consecutive zeros immediately preceding the -th element in the sequence of entries of a matrix arranged in the row-major order. Let be the value of the -th element. We define Format 3 as the number sequence where the two integers and for all such that are arranged in the ascending order of . For example, the matrix
is represented as
0, 1, 0, -5, 2, 3in Format 3.
(3) Number sequences representing matrices in Format 3 are stored in files. For each of the matrices obtained by transposing the following matrices, find the row such that the sum of the entries is the largest, and write down on the answer sheet its row number and the sum of its entries. If there are two or more such rows, answer about one of them.
(a) The matrix with 4 rows and 6 columns stored in data3a.txt.
(b) The matrix with 100 rows and 150 columns stored in data3b.txt.
(c) The matrix with data3c.txt.