Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created June 1, 2021 01:08
Show Gist options
  • Save sakapon/0594c751783840f86cb3c4463ad6e639 to your computer and use it in GitHub Desktop.
Save sakapon/0594c751783840f86cb3c4463ad6e639 to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q022
using System;
using System.Linq;
class Q022
{
static void Main()
{
var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
var g = a.Aggregate(Gcd);
Console.WriteLine(a.Sum(x => x / g - 1));
}
static long Gcd(long a, long b) { for (long r; (r = a % b) > 0; a = b, b = r) ; return b; }
}
@sakapon
Copy link
Author

sakapon commented Jun 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment