|
|
back to boardthe solution is achieved using LCM (MCM in Spanish) and long long to express the result no is necesary GCD > 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 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 :) 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. |
|
|