ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1024. Перестановки

Alexander J. Villalba G. LCM and long long [4] // Задача 1024. Перестановки 16 апр 2011 06:29
the solution is achieved using LCM (MCM in Spanish) and long long to express the result
Alexander J. Villalba G. Re: LCM and long long [3] // Задача 1024. Перестановки 16 апр 2011 06:30
no is necesary GCD
Evgeniy++ Re: LCM and long long [2] // Задача 1024. Перестановки 17 июл 2011 03:09
> long long to express result

Correct! Overflow can happen otherwise.

Edited by author 17.07.2011 03:09

Edited by author 17.07.2011 03:09
Ignas Re: LCM and long long [1] // Задача 1024. Перестановки 8 авг 2011 22:13
The final answer fits int type. BUT when you multiply two ints, you must convert the product to long long. After that you divide the product and the answer doesn't exceed int range :)
Savchenkov (NNSTU) Re: LCM and long long // Задача 1024. Перестановки 28 окт 2011 00:23
NO! You don't need long long!

Instead of:   a * b / gcd(a,b)
Use this:     a / gcd(a,b) * b

This way you won't get overflow.