|
|
вернуться в форумLCM and long long the solution is achieved using LCM (MCM in Spanish) and long long to express the result Re: LCM and long long no is necesary GCD Re: LCM and long long > 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 Re: LCM and long long Послано Ignas 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 :) Re: LCM and long long 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. |
|
|