Largest Pair GCD Shortcut
Preview mode. Log in to edit, run, submit, and save progress.
Easy
Largest Pair GCD Shortcut
For each integer n, an audit asks for the largest possible greatest common divisor of two distinct positive integers that are not greater than n. Report only that maximum gcd value. Input Format: The first line contains t, the number of test cases. Each test case contains n. Output Format: For each test case, print the maximum possible gcd.
Examples
Example 1
Input:
1 10
Output:
5
Explanation: The pair 10 and 5 has gcd 5, and no valid pair can have a larger gcd.
Approach hint
Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp