ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Арифметика > задача:


50527 - Sum of LCMs

Задачи раздела

• 50870 - ZScore normalization
• 50797 - Nr of Missing Guests
• 50518 - Histogram Equalization
• 50522 - Multiplication Table - 2
• 50814 - Buying Books from Internet
• 50812 - Total Discount for the clients
• 51003 - Double Prime
• 50435 - City Electric Bills
• 50527 - Sum of LCMs
• 50440 - Call Center
• 50342 - 100 Factorial
• 50439 - Telephone Calls
• 50436 - Pocket Money
• 50379 - a^b modulus k
• 50353 - Cube of the Largest number
• 50359 - Mode of a Series
• 50539 - Number of Chairs - 2

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Sum of Least Common Multiples (LCM)

Question: Assume that you are given the following functions and they are working properly (in the library LCM.h).   

  #include "utils/LCM.h" 

  void getNums(int &num1, int &num2);
  int GCD(int m, int n);
where getNums gets two numbers from an input stream and GCD calculates and returns the greatest common divisor of two numbers given.

Then, LCM of two numbers can be calculated as follows:

  • first calculate the GCD of given numbers
  • then, each number is divided by GCD (let's say that results are stored in res1 and res2)
  • Then, LCM is the product of GCD, res1, and res2.

Question: Write a program that reads n pairs of numbers using getNums function. Then, the program calculates the LCM of each pair, and, shows the sum of LCMs in the end.

Input specification
You will be first given the number of number pairs (n) where n is between 0 and 1000. Then, get n number pairs (using getNums function). Each number is between 1 and 100000.

Output specification
Show one integer.

Для отправки решений необходимо выполнить вход.

www.contester.ru