CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O

Problem 50: Greatest Common Divisor

Two integers A and B are given on one line, separated by a single space. Output the greatest common divisor of A and B on one line.

Constraints

1 ≤ A, B ≤ 1000000

Input example 1

12 18

Output example 1

6

Input example 2

7 5

Output example 2

1

What you'll train

Communicate the purpose

What you get

  • Specify the algorithm
  • Express the input format
  • Express the output format

How to ask the AI

Clearly state that what you want is the greatest common divisor, and it's a good idea to also specify the implementation approach, such as using math.gcd or the Euclidean algorithm.

If you ask vaguelyIf the goal is left ambiguous, the AI may end up writing code that calculates the least common multiple instead of the greatest common divisor.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。