ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1024. Permutations

Alexander J. Villalba G. LCM and long long [4] // Problem 1024. Permutations 16 Apr 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] // Problem 1024. Permutations 16 Apr 2011 06:30
no is necesary GCD
Evgeniy++ Re: LCM and long long [2] // Problem 1024. Permutations 17 Jul 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] // Problem 1024. Permutations 8 Aug 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 // Problem 1024. Permutations 28 Oct 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.