[プログラマー]無傷の矩形


📖 質問する


https://programmers.co.kr/learn/courses/30/lessons/62048

💻 マイコード

def solution(w,h):
    
    m1=max(w, h)
    n1=min(w, h)
    
    while n1:
        m1, n1=n1, m1%n1
    
    return w*h-(w+h-m1)

💡 プールおよびその他のコード

  • 最大公約数:ユークリッド湖製法
  • を用いる
    コメントブログ
    組み込み関数の使用
    import math
    def solution(w,h):
    	return w*h-(w+h-math.gdc(w,h))