<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>leo-x.log</title>
        <link>https://velog.io/</link>
        <description>현실에 안주하지 않는</description>
        <lastBuildDate>Fri, 02 Apr 2021 15:35:13 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>leo-x.log</title>
            <url>https://images.velog.io/images/leo-x/profile/dc52d0a2-4eb3-4268-a038-9e83bb1519cc/Best Lebanese Hummus Recipe.jpg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. leo-x.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/leo-x" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[프로그래머스 해시 전화번호목록]]></title>
            <link>https://velog.io/@leo-x/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B4%EC%8B%9C-%EC%A0%84%ED%99%94%EB%B2%88%ED%98%B8%EB%AA%A9%EB%A1%9D</link>
            <guid>https://velog.io/@leo-x/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B4%EC%8B%9C-%EC%A0%84%ED%99%94%EB%B2%88%ED%98%B8%EB%AA%A9%EB%A1%9D</guid>
            <pubDate>Fri, 02 Apr 2021 15:35:13 GMT</pubDate>
            <description><![CDATA[<pre><code>def solution(phone_book):
    answer=True
    for i in range(0,len(phone_book)):
        for j in range(i+1,len(phone_book)):
            if (phone_book[i].startswith(phone_book[j]) or phone_book[j].startswith(phone_book[i])):
                answer=False
    return answer</code></pre><p>정확성 테스트 통과
효율성 테스트 실패 ㅠ
뭐가 문제일까</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[프로그래머스 해시 완주하지못한선수]]></title>
            <link>https://velog.io/@leo-x/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B4%EC%8B%9C-%EC%99%84%EC%A3%BC%ED%95%98%EC%A7%80%EB%AA%BB%ED%95%9C%EC%84%A0%EC%88%98</link>
            <guid>https://velog.io/@leo-x/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B4%EC%8B%9C-%EC%99%84%EC%A3%BC%ED%95%98%EC%A7%80%EB%AA%BB%ED%95%9C%EC%84%A0%EC%88%98</guid>
            <pubDate>Fri, 02 Apr 2021 12:28:11 GMT</pubDate>
            <description><![CDATA[<p>링크:<a href="https://programmers.co.kr/learn/courses/30/lessons/42576">https://programmers.co.kr/learn/courses/30/lessons/42576</a></p>
<pre><code>def solution(participant, completion):
    tmp=participant
    tmp2=completion
    for i in range(0,len(participant)):
        for j in range(0,len(completion)):
            if participant[i]==completion[j]:
                tmp.pop(i)
                tmp.insert(i,&quot;0&quot;)
                tmp2.pop(j)
                tmp2.insert(j,&quot;0&quot;)

    answer=&quot;&quot;
    for k in range(0,len(participant)):
        if tmp[k]!=&quot;0&quot;: answer=tmp[k]

    return answer</code></pre><p>정확성 테스트는 통과
효율성 테스트는 0점을 받았다 ㅠ</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[백준11050번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%8011050%EB%B2%88</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%8011050%EB%B2%88</guid>
            <pubDate>Wed, 31 Mar 2021 13:20:49 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준11050번

def binomial(n,k):
    if (n==k)or(k==0):
        return 1
    else :
        return binomial(n-1,k-1)+binomial(n-1,k)

n1,k1=map(int,input().split())

print(binomial(n1,k1))</code></pre><p>재귀함수를 이용함</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[백준2869번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%802869%EB%B2%88</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%802869%EB%B2%88</guid>
            <pubDate>Wed, 31 Mar 2021 11:34:57 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준2869번
a,b,v=map(int,input().split())

distance=0
count=0
while(1):
    count=count+1
    distance=distance+a
    if distance &gt;= v:
        break
    else:
        distance=distance-b

print(count)</code></pre><p>예제 입력 1 
2 1 5
예제 출력 1 
4</p>
<p>예제 입력 2 
5 1 6
예제 출력 2 
2</p>
<p>예제 입력 3 
100 99 1000000000
예제 출력 3 
999999901
-&gt;여기 3번째 test case에서 시간이 초과되었다 ㅠ 수학적인 방법을 동원해서 연산시간을 줄여야 할것 같다 (저 코드로는 big O가 큰듯)</p>
<pre><code>#백준2869번
a,b,v=map(int,input().split())

left=v
count=1
while(left&gt;a+(a-b)):
    count=count+1
    left=left-(a-b)
count=count+1

print(count)</code></pre><p>다른 방식으로 코드를 써봐도, 3번째 test case 에서 시간 초과 ㅠ</p>
<p>예제 입력을 하나씩 다시 따져봤다.
이번에는 거꾸로 연산을 해봤다.</p>
<h4 id="2-1-5-test-case">2 1 5 test case</h4>
<p>5
-2<strong>*1</strong>    (2를 먼저 뺀다)
3
-(2-1)<strong>*3</strong>     (남은 값에서 (2-1)의 배수만큼 뺀다)
0</p>
<h4 id="5-1-6-test-case">5 1 6 test case</h4>
<p>6
-5<strong>*1</strong>     (5를 먼저 뺀다)
1
-(5-1)<strong>*1</strong>     (남은 값에서 (5-1)의 배수만큼 뺀다)
-3</p>
<h4 id="100-99-1000000000-test-case">100 99 1000000000 test case</h4>
<p>1000000000
-100<strong>*1</strong>    (100을 먼저 뺀다)
999999900
-(100-99)<strong>*999999900</strong>    (남은 값에서 (100-99)의 배수만큼 뺀다)
0</p>
<p>이런 방식을 코드로 작성하면 다음과 같다.</p>
<pre><code>#백준2869번
a,b,v=map(int,input().split())

left=v
count=0

left=left-a
count=count+1

if left%(a-b)==0:
    count=count+(left//(a-b))
else :
    count=count+((left//(a-b))+1)

print(count)</code></pre><p>정답!</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[백준1259번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%801259%EB%B2%88</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%801259%EB%B2%88</guid>
            <pubDate>Wed, 31 Mar 2021 10:58:23 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준1259번

def palin(l):
    tmp2=[]
    palin_check=True
    for i2 in range(0,len(l)):
        tmp2.append(l[i2])
    for i3 in range(0,(len(l)//2)+1):
        if tmp2[i3]==tmp2[(len(tmp2)-1)-i3]:
            continue
        else :
            palin_check=False
            break

    if palin_check==True:
        return &#39;yes&#39;
    else :
        return &#39;no&#39;

input_lst=[]
while(1):
    tmp=input()
    if tmp==&#39;0&#39; :
        break
    else :
        input_lst.append(list(tmp))

for i in range(0,len(input_lst)):
    print(palin(input_lst[i]))</code></pre><p><strong>문자열 철자 하나씩 끊어 list로 저장하는 법</strong>
s = &quot;hello python!&quot;
print(list(s))
-&gt;[&#39;h&#39;, &#39;e&#39;, &#39;l&#39;, ..., &#39;!&#39;] 이렇게 나옴</p>
<pre><code>#백준1259번 다른사람 풀이
import sys

def my_palindrome(str):
    length = len(str)
    for i in range(0, length):
        if(str[i] != str[length - 1 - i]):
            return &quot;no&quot;

    return &quot;yes&quot;

while(True):
    text = sys.stdin.readline().strip()
    if text == &#39;0&#39;:
        break
    print(my_palindrome(text))</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[백준2798번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%802798%EB%B2%88</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%802798%EB%B2%88</guid>
            <pubDate>Sat, 27 Mar 2021 14:35:56 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준2798번

n,m=map(int,input().split())
lst=[]
for i in input().split():
    lst.append(int(i))
#입력받은 n의 크기에 상관없이 더 큰 크기의 리스트를 만들수 있음

front=0
mid=1
back=2
lst2=[]

while(back&lt;=n-1):
    while(mid&lt;=back-1):
        while(front&lt;=mid-1):
            lst2.append(lst[front]+lst[mid]+lst[back])
            front=front+1
        front=0
        mid=mid+1
    mid=1
    back=back+1

lst2.sort()
maxValue=lst2[0]
for i in range(1,len(lst2)):
    if lst2[i]&gt;m: break
    if lst2[i]&gt;maxValue:
        maxValue=lst2[i]
print(maxValue)</code></pre><hr>
<pre><code>#백준2798번 다른풀이

n,m=map(int,input().split())
lst=list(map(int,input().strip().split()))[:n]#입력받은 n의 크기 만큼만 리스트를 만듬

#--------------------이 밑으로는 위와 동일한 코드
front=0
mid=1
back=2
lst2=[]

while(back&lt;=n-1):
    while(mid&lt;=back-1):
        while(front&lt;=mid-1):
            lst2.append(lst[front]+lst[mid]+lst[back])
            front=front+1
        front=0
        mid=mid+1
    mid=1
    back=back+1

lst2.sort()
maxValue=lst2[0]
for i in range(1,len(lst2)):
    if lst2[i]&gt;m: break
    if lst2[i]&gt;maxValue:
        maxValue=lst2[i]
print(maxValue)</code></pre><pre><code>#백준2798번 다른풀이2(다른사람풀이)
def P(n,m,c):
    t=set()
    for i in range(n-2):
        for o in range(i+1,n-1):
            for p in range(o+1,n):
                s=c[i]+c[o]+c[p]
                if s&lt;=m:
                    t.add(s)
                    break

    return max([*t])
print(P(*map(int,input().split()),list(sorted(map(int,input().split()))[::-1])))</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[백준10250번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%8010250%EB%B2%88</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%8010250%EB%B2%88</guid>
            <pubDate>Sat, 27 Mar 2021 08:18:23 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준10250번
#몫과 나머지 연산자 이용

def reco(h,w,n):
    if n%h==0:
        room=(h*100)+((n//h))
    else:
        room=((n%h)*100)+((n//h)+1)
    return room

cases=int(input())  
lst=[]  
for i in range(0,cases):
    h,w,n=map(int,input().split())
    lst.append(reco(h,w,n))
for i in range(0,cases):
    print(lst.pop(0))</code></pre><hr>
<pre><code>#백준10250번 다른풀이
#좌표 움직이는 방식

def reco(h,w,n):
    x=1
    y=1
    for i in range(0,n-1):
        if y&lt;h:y=y+1
        else :
            y=1
            x=x+1
    return 100*y+x
#-------------------------이 밑으론 첫번째풀이와 동일
cases=int(input())  
lst=[]  
for i in range(0,cases):
    h,w,n=map(int,input().split())
    lst.append(reco(h,w,n))
for i in range(0,cases):
    print(lst.pop(0))</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[백준1085번]]></title>
            <link>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%80-1085%EB%B2%88-%EB%AC%B8%EC%A0%9C</link>
            <guid>https://velog.io/@leo-x/%EB%B0%B1%EC%A4%80-1085%EB%B2%88-%EB%AC%B8%EC%A0%9C</guid>
            <pubDate>Sat, 27 Mar 2021 08:08:28 GMT</pubDate>
            <description><![CDATA[<pre><code>#백준1085번
x,y,w,h = map(int,(input().split()))

min = x
if (w-x)&lt;min:min=(w-x)
if y&lt;min:min=y
if (h-y)&lt;min:min=(h-y)
print(min)</code></pre><pre><code>#백준1085번 다른풀이
x,y,w,h = map(int,(input().split()))
print(min(x,y,w-x,h-y))</code></pre><p><strong>split() 함수</strong>
문자열의 끝에 .split(&quot;뭐시기&quot;)를 붙이면,
=&gt;문자열을 &#39;뭐시기&#39;를 기반으로 나누어, 새로운 리스트를 리턴한다.
(인자를 아무것도 안넣고 그냥 .split()을 붙이면, 문자열을 공백(whitespace)을 기반으로 나누어, 리스트를 리턴)</p>
<p><strong>strip() 함수(참고)</strong>
문자열의 끝에 .strip()을 붙이면,
=&gt;문자열의 &#39;맨앞&#39;과, &#39;맨뒤&#39; 의 whitespace가 제거가 된다. 단, 중간중간의 whitespace는 제거가 되지 않는다.</p>
]]></description>
        </item>
    </channel>
</rss>