File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ '''
2+ [문제] : https://school.programmers.co.kr/learn/courses/30/lessons/12924#
3+ [Flow]
4+ 연속된 자연수의 조합-> two point
5+ 0. 초기화
6+ start == end-1 = 0
7+ while end <= len(words) and start < end
8+ 1. sum(words[start,end]) < target
9+ -> end += 1
10+ 2. sum(words[start,end]) == target
11+ -> count += 1
12+ -> start += 1
13+ -> end = start +1
14+
15+ 3. sum(words[start,end]) > 0
16+ -> 2와 동일
17+
18+ '''
19+ def solution (n ):
20+ answer = 1 # 본인= target
21+ start = 0 ; end = start + 1 ;
22+ answer_li = []
23+ half = round (n // 2 ) + 2
24+ field = range (1 ,half ) # 반올림
25+ field = list (field )
26+
27+ while n > 2 and end <= len (field ) and start < end and start < len (field ): #
28+ current = sum (field [start : end ])
29+ if current < n :
30+ end += 1
31+ else : # currnet >= n
32+ if current == n :
33+ answer += 1
34+ answer_li .append ([start , end ])
35+ start += 1
36+ end = start + 1
37+ return answer
You can’t perform that action at this time.
0 commit comments