Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Кварталы
- {
- class Program
- {
- static public int QuarterCalculation(int x, int y)
- {
- if ((x == y) ||(x % y == 0 || y % x == 0))
- return Math.Max(x, y);
- var d = Math.Min(x, y);
- while (x % d != 0 || y % d != 0)
- d--;
- if (d == 1)
- return x + y - 1;
- else
- {
- x = x / d;
- y = y / d;
- return (x + y - 1) * d;
- }
- }
- static void Main(string[] args)
- {
- var str = "";
- var str1 = "";
- var str2 = "";
- int x, y;
- int i = 0;
- str = Console.ReadLine();
- while (str[i] != ' ')
- {
- str1 += str[i];
- i++;
- }
- i++;
- while (i < str.Length)
- {
- str2 += str[i];
- i++;
- }
- x = int.Parse(str1) - 1;
- y = int.Parse(str2) - 1;
- //Console.WriteLine(x);
- //Console.WriteLine(y);
- Console.WriteLine(QuarterCalculation(x, y));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement