DO NOT: Square Sum

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

E

COMP6047 – Algorithm and Programming

T
T
NO
BU
Square Sum
Jojo gives Lili a question. In the question, Jojo will give Lili a 4x4 square which is
described below.

a/1 b/2 c/3 d/4

I
b/2 c/3 d/4 c/3

R
c/3 d/4 c/3 b/2
O
d/4 c/3 b/2 a/1

Given integers a, b, c and d. Integers b, c, and d are not guaranteed to be divisible by


T
D

2, 3, 4 respectively. Calculate the total sum of the square. Unfortunately, Lili cannot
answer Jojo’s question correctly. Help Lili by making a program that will help her to
S
answer Jojo’s question correctly.

Format Input
DI

The input consists of 3 lines. Each line consists of 4 integers.

Format Output
OT
UT
RE

The output consists of 3 lines. Each line consists of total sum with 2 decimal points.

Constraints
0 ≤ a, b, c, d ≤ 100 (The value of each variable always lie between 0 and 100)
N
IB
Sample Input (standard input)
0 0 0 0
1 2 3 4
TR
DO

2 4 9 16

Sample Output (standard output)


0.00
IS

16.00
46.00
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
Explanation

NO
BU
On the second line, the variable a = 1, b = 2, c = 3, d = 4. Therefore, the square is

1/1 2/2 3/3 4/4


2/2 3/3 4/4 3/3
3/3 4/4 3/3 2/2
4/4 3/3 2/2 1/1

I
So the value in square is equal to

R
O
1 1 1 1
1 1 1 1
1 1 1 1
T
D

1 1 1 1

So, the total sum of the square is 16.


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
NO
BU
Square Sum
Jojo memberikan Lili sebuah soal. Di soal tersebut, Jojo akan memberikan Lili sebuah
kotak berukuran 4x4 seperti berikut:

a/1 b/2 c/3 d/4

I
b/2 c/3 d/4 c/3

R
O
c/3 d/4 c/3 b/2
d/4 c/3 b/2 a/1
T
Diberikan sebuah bilangan bulat positif a, b, c dan d. Bilangan b, c dan d tidak dipastikan
D

dapat dibagi habis dengan 2, 3, 4, dst. Hitunglah jumlah total dari kotak tersebut. Lili
tidak dapat menjawab soal Jojo. Lili akhirnya meminta bantuan Anda untuk membuat
S
sebuah program yang dapat memberikan jawaban dari soal Jojo dengan benar.

Format Input
DI

Input terdiri dari 3 baris. Setiap baris terdiri dari 4 bilangan bulat positif.

Format Output
OT
UT
RE

Output terdiri dari 3 baris. Setiap baris terdiri dari jawaban berupa bilangan dengan 2
angka dibelakang koma.

Constraints
N
0 ≤ a, b, c, d ≤ 100
IB
Sample Input (standard input)
0 0 0 0
TR
DO

1 2 3 4
2 4 9 16

Sample Output (standard output)


IS

0.00
16.00
46.00
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
Explanation

NO
BU
Pada baris kedua, a = 1, b = 2, c = 3, d = 4. Kotak tersebut merupakan

1/1 2/2 3/3 4/4


2/2 3/3 4/4 3/3
3/3 4/4 3/3 2/2
4/4 3/3 2/2 1/1

I
Nilai dari kotak tersebut adalah

R
O
1 1 1 1
1 1 1 1
1 1 1 1
T
D

1 1 1 1

Sehingga jumlah total dari kotak tersebut adalah 16.


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.

You might also like