Post

leetcode(리트코드)-1952 Three Divisors(PYTHON)

leetcode 1952 - Three Divisors 문제입니다.

1. 문제

https://leetcode.com/problems/three-divisors/


2. Input , Output


3. 분류 및 난이도

Eazy 난이도 문제입니다.


4. 문제 해석

  • n이 들어옵니다.
  • n이 3개의 약수를 가지면 True 아니면 False를 리턴하세요.

5. code

코드설명

python

1
2
3
4
5
6
7
8
9
10
11
class Solution:
    def isThree(self, n: int) -> bool:
        count = 0 
        for i in range(1,n+1):
            if n % i == 0 :
                count+=1
                if count >3 :
                    return False
        return True if count == 3 else False
            
                            

6. 결과 및 후기, 개선점

필요시 c++로 짜드립니다.

설명이 필요하다면 댓글을 달아주세요.

This post is licensed under CC BY 4.0 by the author.