IOM 2017, Блиц — Задача 11

OLYMPIAD OF METROPOLISES. Moscow, September 4 · 4 септември 2017 г.

Условие

In The Nine Chapters on the Mathematical Art, a Chinese mathematics book composed by several generations of scholars from the 10th - 2nd century BCE, an algorithm called “Subtracting Each Other Technique” was recorded. Here is an implementation of this algorithm in Visual Basic.

Visual Basic listing: Private Sub Command1_Click(); Dim a,b,c,r,t As Integer; a = Val(InputBox('Input The First Number')); b = Val(InputBox('Input The Second Number')); c = 0; Do While a Mod 2 = 0 And b mod 2 = 0: a = a / 2, b = b / 2, c = c + 1, Loop; Do While a <> b: If a < b Then t = a, a = b, b = t, End If; r = a - b; a = b; b = r; Loop; Print r*2^c; End Sub.

Provide the output of the program after entering two numbers, a = 98 and b = 63.

Отговори

Решение


Оригинал в Архива: blitz.pdf · официални решения: answers-blitz.pdf