GCD Of Differences
Computer Mathematics
Hard
2 views
Problem Description
Given n numbers, print gcd of all |ai-a1|.
Input Format
n then n integers.
Output Format
One integer.
Official Solution
Compute base=a1. For i>=2 take d=abs(ai-base), g=gcd(g,d). Output g.
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!