0% found this document useful (0 votes)
2 views5 pages

Prob F

Jojo, Lili, and Bibi are friends who enjoy mathematics, and Jojo is preparing for a speed math competition with their help. Jojo needs to multiply three N x N matrices provided by Lili and Bibi, and a program is required to automate this multiplication for multiple test cases. The output should display the results in a specified format for each test case.

Uploaded by

raynaldydk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Prob F

Jojo, Lili, and Bibi are friends who enjoy mathematics, and Jojo is preparing for a speed math competition with their help. Jojo needs to multiply three N x N matrices provided by Lili and Bibi, and a program is required to automate this multiplication for multiple test cases. The output should display the results in a specified format for each test case.

Uploaded by

raynaldydk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

E

COMP6047 – Algorithm and Programming

T
T
NO
BU
Get Some Results
Jojo, Lili, and Bibi are very good friends. The three of them share a common love for
numbers. As such, they often study the art of mathematics together. One day, Jojo
mentioned that he had registered himself in a speed math competition. Jojo needs to
train hard in order to win the competition.

R I
O
Lili and Bibi decided to help Jojo train. They will each give Jojo a matrix of size N × N .
Jojo needs to multiply these two matrices together. For extra fun, they also asked Jojo
to write his own matrix below their matrices and to multiply that too.
T
D

Formally, Jojo will have three matrices. Jojo needs to multiply these three matrices
together in the order they were written, top to bottom.
S
For verification purposes, Jojo has asked for your help to write a computer program that
will do the calculations automatically given the three matrices Jojo needs to multiply.
DI

Help Jojo train!

Format Input
OT
UT
The first line of input consists of one integer T , the number of test cases that will be given.
RE

The first line of each test case consists of one integer N , the size of the matrices as
explained in the problem statement. Then follows three matrices of size N × N . There
is an empty line after every matrix.
N
IB
Format Output
For each test case, the first line of output should express the format “Case #X:” where
X is the current test case number, starting from 1. The following N lines should contain
the final matrix after multiplication. There are no trailing spaces in any row.
TR
DO

Constraints
• 1 ≤ T ≤ 10

• 1 ≤ N ≤ 50
IS

• Every element in each matrix is an integer number between 0 and 10 inclusive.


ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
Sample Input (standard input)

NO
BU
2
2
3 4
10 9

2 2

I
5 5

R
O
3 4
10 9

3
T
D

1 0 0
0 1 0
0 0 1
S
2 3 5
DI

4 1 2
2 2 3

0 0 1
0 1 0
OT
UT
1 0 0
RE

Sample Output (standard output)


Case #1:
N
IB
338 338
845 845
Case #2:
5 3 2
2 1 4
TR
DO

3 2 2
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
NO
BU
Get Some Results
Jojo, Lili, dan Bibi adalah sekelompok teman yang sangat akrab. Mereka bertiga menyukai
segala hal yang berhubungan dengan angka. Oleh karena itu, mereka bertiga sering
mempelajari seni matematika bersama-sama. Suatu hari, Jojo mengatakan bahwa ia
telah mendaftarkan dirinya di suatu kompetisi hitung cepat matematika. Jojo harus

I
berlatih keras agar dapat memenangkan kompetisi tersebut.

R
O
Lili dan Bibi memutuskan untuk membantu Jojo berlatih. Mereka masing-masing memberikan
Jojo suatu matrix berukuran N × N . Jojo harus mengalikan kedua matrix tersebut.
T
Untuk tantangan ekstra, mereka juga meminta Jojo untuk menuliskan matrix baru yang
D

ia buat sendiri di bawah matrix yang mereka berikan. Jojo juga harus mengalikan matrix
buatannya sendiri tersebut.
S
Secara formal, Jojo akan memiliki tiga matrix. Jojo harus mengalikan ketiga matrix
tersebut secara berurutan sesuai dengan urutan penulisan mereka, dari atas ke bawah.
DI

Untuk memastikan jawabannya benar, Jojo meminta bantuanmu untuk membuat suatu
program komputer yang akan melakukan perhitungan tersebut secara otomatis setelah
menerima masukan tiga matrix yang harus Jojo kalikan. Bantulah Jojo berlatih!
OT
UT
RE

Format Input
Baris pertama input berisi sebuah bilangan bulat T , jumlah dari test case yang akan
diberikan.
N
IB
Baris pertama dari setiap test case berisi sebuah bilangan bulat N , ukuran matrix seperti
yang sudah dijelaskan di deskripsi soal. Kemudian akan ada tiga matrix berukuran N ×N .
Setelah setiap matrix, akan ada sebuah baris kosong.
TR
Format Output
DO

Untuk setiap test case, baris pertama output mengikuti format “Case #X:” dimana
X merupakan nomor test case, dimulai dari 1. N baris berikutnya berisi matrix akhir
setelah perkalian. Tidak ada trailing space di semua baris.

Constraints
IS

• 1 ≤ T ≤ 10

• 1 ≤ N ≤ 50
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
• Semua elemen pada setiap matrix merupakan bilangan bulat antara 0 sampai
dengan 10 inklusif.

NO
IBU
R
O
T
D
S
DI

OT
UT
RE

N
IB
TR
DO
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
Sample Input (standard input)

NO
BU
2
2
3 4
10 9

2 2

I
5 5

R
O
3 4
10 9

3
T
D

1 0 0
0 1 0
0 0 1
S
2 3 5
DI

4 1 2
2 2 3

0 0 1
0 1 0
OT
UT
1 0 0
RE

Sample Output (standard output)


Case #1:
N
IB
338 338
845 845
Case #2:
5 3 2
2 1 4
TR
DO

3 2 2
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.

You might also like