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

Сборники > Задачи со всего света > задача:


50527 - Sum of LCMs

Задачи сборника

• 50926 - School Mail Merge
• 50917 - Descending Numbers
• 50982 - A thief in labyrinth
• 50980 - The smallest rectangle
• 50932 - Shifting rows and columns
• 50933 - Sum of the Biggest Neighbors
• 50834 - The train which leaves the f...
• 50435 - City Electric Bills
• 50527 - Sum of LCMs
• 51012 - Palindrome-k
• 50469 - Letter Grades
• 50539 - Number of Chairs - 2
• 003. 50432 - Numbers and Squares
• 004. 50433 - Sum of Cubes
• 005. 50595 - Shuma e numrave
• 016. 50459 - The Biggest Digit
• 020. 50575 - Numri i numrave prim

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

Если у вас есть предложения или пожелания по работе 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