brewersfan1976

count_black_cells.py

Sep 24th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.14 KB | None | 0 0
  1. from fractions import gcd
  2.  
  3. def countBlackCells(n, m):
  4.     g = gcd(n, m)
  5.     n /= g
  6.     m /= g
  7.    
  8.     return g * (n + m - 1) + 2 * (g - 1)
Advertisement
Add Comment
Please, Sign In to add comment