Skip to content

平成31年度 春期 ITパスポート試験 問71

This question's explanation and your answers so far.

問71
頻出度★★☆

図1のように二つの正の整数 A1, A2を入力すると, 二つの数値 B1, B2を出力するボックスがある。B1は A2と同じ値であり, B2は A1を A2で割った余りである。図2のように, このボックスを2個つないだ構成において, 左側のボックスの A1として49, A2として11を入力したとき, 右側のボックスから出力される B2の値は幾らか。

出典 平成31年度 春期 ITパスポート試験 問71
解説

問 71

  • ア

    正解 For an input (A1, A2), the box outputs A2 directly as B1, and the remainder of A1 divided by A2 as B2. First, the left box has A1=49 and A2=11, so it outputs B1=11 and B2 = the remainder of 49÷11 = 5. In the wiring of Figure 2, the left box output (B1, B2)=(11, 5) connects directly to the right box input (A1, A2)=(11, 5). Therefore the right box computes with A1=11 and A2=5, and the required B2 is the remainder of 11÷5 = 1. Hence the value of B2 output from the right box is 1, so ア is correct.

  • Incorrectイ

    2 is the value obtained by taking the “quotient” of the right box computation 11÷5 (2 remainder 1). This box outputs not the quotient but the “remainder”, so it is wrong. The correct value is the remainder, 1.

  • Incorrectウ

    4 is the value obtained by taking the “quotient” of the left box computation 49÷11 (4 remainder 5). The box outputs the remainder rather than the quotient, and moreover the question asks for the right box output, so it is doubly wrong.

  • Incorrectエ

    5 is the left box B2 (the remainder of 49÷11 = 5), i.e., an intermediate result. The question asks for the right box B2, so this is the error of stopping at the first stage. One must continue computing through the right box up to the remainder of 11÷5 = 1.

ここがポイント
  • When given (A1, A2) as input, the box outputs (B1=A2, B2 = remainder of A1 divided by A2). This corresponds to one step of the Euclidean algorithm.
  • In a configuration where two boxes are connected in series, the output of the left box becomes directly the input of the right box. Compute stage by stage in order, and read off the output of the final box.
用語

Your answers