<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>프로그래밍 일지</title>
    <link>https://eugene-lab.tistory.com/</link>
    <description>ㅤ</description>
    <language>ko</language>
    <pubDate>Thu, 2 Jul 2026 06:47:40 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>bouble12</managingEditor>
    <image>
      <title>프로그래밍 일지</title>
      <url>https://tistory1.daumcdn.net/tistory/3973588/attach/cb9562c1f8964b8589930a8ad6192f36</url>
      <link>https://eugene-lab.tistory.com</link>
    </image>
    <item>
      <title>[Unity] 슈팅게임 개발</title>
      <link>https://eugene-lab.tistory.com/139</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;아군 비행기&lt;/p&gt;
&lt;pre id=&quot;code_1689610161348&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Friendly_ship : MonoBehaviour
{
    public float moveSpeed = 5.0f;
    public bool canShoot = true;
    public float shootDelay;
    public float shootTimer = 0.0f;
    public VariableJoystick joystick;
    private Camera _mainCam;
    public Entity _entity;
    

    // Start is called before the first frame update
    void Start()
    {
        _mainCam = Camera.main;  //유니티 생성시 만들어지는 기본 카메라
        _entity = GetComponent&amp;lt;Entity&amp;gt;();
        _entity.isPlayer = true;
    }

    // Update is called once per frame
    void Update()
    {
        //카메라 외부로 나갈 수 X
        Vector3 pos = _mainCam.WorldToViewportPoint(transform.position); //메인카메라를 뷰포트값으로 설정 (좌측하단 0,0 우측하단 1,1)
        if (pos.x &amp;lt; 0f) pos.x = 0f;
        if (pos.x &amp;gt; 1f) pos.x = 1f;
        if (pos.y &amp;lt; 0f) pos.y = 0f;
        if (pos.y &amp;gt; 1f) pos.y = 1f;
        transform.position = _mainCam.ViewportToWorldPoint(pos);
        
        //이동
        MoveControl();
        
    }

    private void MoveControl()
    {
        float xInput = Input.GetAxis(&quot;Horizontal&quot;) + joystick.Horizontal;
        float distanceX = xInput * Time.deltaTime * moveSpeed;
        this.gameObject.transform.Translate(distanceX, 0, 0);
        float yInput = Input.GetAxis(&quot;Vertical&quot;) + joystick.Vertical;
        float distanceY = yInput * Time.deltaTime * moveSpeed;
        this.gameObject.transform.Translate(0, distanceY, 0);
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.TryGetComponent(out enemy hit))
        {
            _entity.TakeDamage(1);
            hit.entity.TakeDamage(hit.entity.maxHealth);
        }
        if (other.TryGetComponent(out bullet hitf))
        {
            if (!hitf.isPlayer)
            {
                _entity.TakeDamage(1);
                Destroy(hitf.gameObject);
            }
        }
    }
    
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;총알&lt;/p&gt;
&lt;pre id=&quot;code_1689610183408&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using UnityEngine;

public class bullet : MonoBehaviour
{
    public float moveSpeed = 10.0f;
    public bool  isPlayer;

    void Update()
    {
        transform.position += transform.right * (moveSpeed * Time.deltaTime);
        Destroy(gameObject, 8f);
    }

    
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;아군 총알 발사&lt;/p&gt;
&lt;pre id=&quot;code_1689610293060&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_Fire : MonoBehaviour
{
    public bullet bulletFactory; //bullet 형식의 원본(?)
    public GameObject firePosition; //쏘는 위치 
    
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Fire();
        }
    }

    public void Fire()
    {
        bullet bulletInst = Instantiate(bulletFactory);
        bulletInst.transform.position = firePosition.transform.position; //총알의 초기위치
        bulletInst.isPlayer = true;
        Destroy(bulletInst, 8f); //8초 이후 삭제
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;체력 - 아군, 적군, 보스 모두 사용할수 있도록 되어있다.&lt;/p&gt;
&lt;pre id=&quot;code_1689610199265&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
//using Debug = System.Diagnostics.Debug;

public class Entity : MonoBehaviour
{
    public int maxHealth = 2;
    public int _curHealth;
    public bool isEnemy;
    public bool isBoss;
    public bool isPlayer;
    public TextScore score;

    void Start()
    {
        _curHealth = maxHealth;
    }

    public void TakeDamage(int damage)
    {
        _curHealth -= damage;
        if (_curHealth &amp;lt;= 0)
        {
            Death();
        }

    }

    private void Death()
    {
        if(isPlayer)
        {
            SceneManager.LoadScene(&quot;Udie&quot;);
        }

        else if (isBoss)
        {
            SceneManager.LoadScene(&quot;Clear&quot;);
        }
        else
        {
            Destroy(gameObject);
            
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;플레이어 체력&lt;/p&gt;
&lt;pre id=&quot;code_1689610320024&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Player_HP : MonoBehaviour
{
    public Slider hpBar;
    public Entity _player;
    
    void Update()
    {

        hpBar.value = (float)_player._curHealth / _player.maxHealth;
        
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;적기&lt;/p&gt;
&lt;pre id=&quot;code_1689610558153&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

public class enemy : MonoBehaviour
{
    public Entity entity;
    public float moveSpeed = 1.5f;

    void Start()
    {
        entity = GetComponent&amp;lt;Entity&amp;gt;();
        entity.isEnemy = true;
    }

    // Update is called once per frame
    void Update()
    {
        transform.Translate(Vector3.right * (moveSpeed * Time.deltaTime));
        if(transform.position.x &amp;lt; -10)
            Destroy(gameObject);
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.TryGetComponent(out bullet hit))
        {
            if (hit.isPlayer)
            {
                entity.TakeDamage(1);
                Destroy(hit.gameObject);
            }
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;적기 총알 발사&lt;/p&gt;
&lt;pre id=&quot;code_1689610580451&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;    using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Fire : MonoBehaviour
{
    public bullet bulletPrefab;

    private Transform player;
    // Start is called before the first frame update
    void Start()
    {
        if (Random.Range(0f, 1f) &amp;lt; 0.95f)
        {
            player = FindObjectOfType&amp;lt;Friendly_ship&amp;gt;().transform;
            Invoke(nameof(Fire), Random.Range(3f, 5f));
        }
    }

    void Fire()
    {
        Vector2 dir = player.position - transform.position;
        bullet newBullet = Instantiate(bulletPrefab);
        newBullet.transform.position = transform.position;
        newBullet.transform.right = dir;
        if(Random.Range(0, 1) == 0)
        {
            newBullet.transform.rotation = transform.rotation;
        }
        newBullet.isPlayer = false;
        Destroy(newBullet.gameObject, 8f);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;적기 생성&lt;/p&gt;
&lt;pre id=&quot;code_1689610616867&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random;

public class EnemyFacto : MonoBehaviour
{
    public  float randomX;
    public  float randomY;
    public bool enableSpawn = true;
    public enemy enemyFactory;
    public TextScore score;

    void SpawnEnemy()
    {
        randomX = Random.Range(10f, 15f);
        randomY = Random.Range(-5f, 5f);
        if (enableSpawn)
        {
            enemy enemyInst = Instantiate(enemyFactory);
            enemyInst.transform.position = new Vector3(randomX, randomY, 0.0f);
            enemyInst.moveSpeed = Random.Range(1f, 3f);
        }
    }

    private void Start()
    {
        InvokeRepeating(&quot;SpawnEnemy&quot;, 5, 1);
    }

    void Update()
    {
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;보스&lt;/p&gt;
&lt;pre id=&quot;code_1689610634450&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections.Generic;
using System.Collections;
using UnityEngine;

public class Boss : MonoBehaviour
{

    public bullet bulletPrefab;
    public bullet bigBulletPrefab;
    public enemy enemyPrefab;
    private Transform player;
    public Vector2 patternIntervalRange;
    private Entity _entity;
    IEnumerator Circle_Fire(int startAngle, float fireRate, int angleRate, float speed)
    {
        float fireAngle = startAngle;
        for (int i = 0; i &amp;lt; 360 / angleRate; i++)
        {
            bullet newBullet = Instantiate(bulletPrefab);
            newBullet.moveSpeed = speed;
            newBullet.transform.position = transform.position;
            Vector2 direction = new Vector2(Mathf.Cos(fireAngle * Mathf.Deg2Rad), Mathf.Sin(fireAngle * Mathf.Deg2Rad));
            newBullet.transform.right = direction;
            fireAngle += angleRate;
            if (fireAngle &amp;gt; 360) fireAngle -= 360; // 0~360
            newBullet.isPlayer = false;
            yield return new WaitForSeconds(fireRate);
        }
        
    }
    IEnumerator Circle_Enemy(int startAngle, float fireRate, int angleRate, float speed)
    {
        float enemyAngle = startAngle;
        for (int i = 0; i &amp;lt; 360 / angleRate; i++)
        {
            enemy newEnemy = Instantiate(enemyPrefab);
            newEnemy.moveSpeed = speed;
            newEnemy.transform.position = transform.position;
            Vector2 direction = new Vector2(Mathf.Cos(enemyAngle * Mathf.Deg2Rad), Mathf.Sin(enemyAngle * Mathf.Deg2Rad));
            enemyAngle += angleRate;
            enemyPrefab.transform.right = direction;
            if (enemyAngle &amp;gt; 360) enemyAngle -= 360; // 0~360
            yield return new WaitForSeconds(fireRate);
        }
        
    }
    // Start is called before the first frame update
    void Start()
    {
        player = FindObjectOfType&amp;lt;Friendly_ship&amp;gt;().transform;
        _entity = GetComponent&amp;lt;Entity&amp;gt;();
        _entity.isBoss = true;
        StartCoroutine(PatternManager());
    }

    IEnumerator Pattern1()
    {
        StartCoroutine(Circle_Fire(15, 0f, 30, 4f));
        yield return StartCoroutine(Circle_Fire(0, 0.1f, 30, 6f));
        for (int i = 0; i &amp;lt; 2; i++)
        {
            StartCoroutine(Circle_Fire(7, 0f, 15, 5f));
            yield return StartCoroutine(Circle_Fire(0, 0.05f, 15, 7f));
        }
    }

    IEnumerator Pattern2()
    {
        for (int i = 0; i &amp;lt; 20; i++)
        {
            Vector2 dir = player.position - transform.position;
            bigBulletPrefab = Instantiate(bigBulletPrefab);
            bigBulletPrefab.moveSpeed = 13f;
            bigBulletPrefab.transform.position = transform.position;
            bigBulletPrefab.transform.right = dir;

            yield return new WaitForSeconds(0.5f);
        }
    }

    IEnumerator Pattern3()
    {
        StartCoroutine(Circle_Enemy(15, 0f, 30, 4f));
        yield return StartCoroutine(Circle_Enemy(0, 0.1f, 30, 6f));
    }
    IEnumerator PatternManager()
    {
        while (true)
        {
            
            yield return new WaitForSeconds(Random.Range(patternIntervalRange.x, patternIntervalRange.y));
            yield return StartCoroutine(Pattern1());
            yield return new WaitForSeconds(Random.Range(patternIntervalRange.x, patternIntervalRange.y));
            yield return StartCoroutine(Pattern2()); 
            yield return new WaitForSeconds(Random.Range(patternIntervalRange.x, patternIntervalRange.y));
            yield return StartCoroutine(Pattern3());
        }
    }
    
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.TryGetComponent(out bullet hit))
        {
            if (hit.isPlayer)
            {
                _entity.TakeDamage(1);
                Destroy(hit.gameObject);
            }
        }
        
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;보스 스폰&lt;/p&gt;
&lt;pre id=&quot;code_1689610650233&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BossSpawn : MonoBehaviour
{
    public EnemyFacto factory;
    public Boss bossPrefab;
    void Start()
    {
        Invoke(nameof(SpawnBoss), 50f);
    }

    void SpawnBoss()
    {
        factory.enableSpawn = false;
        Instantiate(bossPrefab, transform.position, transform.rotation);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;게임 시작 씬넘기기&lt;/p&gt;
&lt;pre id=&quot;code_1689610668399&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class StartGame : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            SceneManager.LoadScene(&quot;Game&quot;);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;재시작&lt;/p&gt;
&lt;pre id=&quot;code_1689610681231&quot; class=&quot;csharp&quot; data-ke-language=&quot;csharp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class RestartGame : MonoBehaviour
{
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            SceneManager.LoadScene(&quot;MainScreen&quot;);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/139</guid>
      <comments>https://eugene-lab.tistory.com/139#entry139comment</comments>
      <pubDate>Tue, 18 Jul 2023 01:18:22 +0900</pubDate>
    </item>
    <item>
      <title>[C++] 이진탐색(binary search) 구현</title>
      <link>https://eugene-lab.tistory.com/138</link>
      <description>&lt;pre id=&quot;code_1689213937215&quot; class=&quot;cpp&quot; data-ke-language=&quot;cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;

using namespace std;

vector&amp;lt;int&amp;gt; A;

int binary(int t, int start, int end)
{
    int mid = (start + end)/2;

    if (start &amp;gt; end)return 0;
    if(t == A[mid])return 1;
    else if(t &amp;gt; mid)start = mid;
    else end = mid;

    binary(t, start+1, end);
    return 0;
}
int main()
{
    int n;
    cin &amp;gt;&amp;gt; n;
    for(int i = 0; i &amp;lt; n; i++) {
        int ipt;
        cin &amp;gt;&amp;gt; ipt;
        A.push_back(ipt);
    }
    int target;
    cin &amp;gt;&amp;gt; target;
    cout &amp;lt;&amp;lt;binary(target, 0, n-1);
}&lt;/code&gt;&lt;/pre&gt;</description>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/138</guid>
      <comments>https://eugene-lab.tistory.com/138#entry138comment</comments>
      <pubDate>Thu, 13 Jul 2023 11:05:42 +0900</pubDate>
    </item>
    <item>
      <title>[C++]백준 25381번: ABBC</title>
      <link>https://eugene-lab.tistory.com/137</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;BC 를 삭제하는 규칙을 먼저 적용하면 그리디를 이용해 쉽게 풀 수 있다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;삭제 대신 B 를 C 로 바꿔주었다.&lt;/p&gt;
&lt;pre id=&quot;code_1676777419683&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;queue&amp;gt;

using namespace std;

int main()
{
    string abbc;
    int ans = 0, b = 0, a = 0;
    cin &amp;gt;&amp;gt; abbc;
    queue&amp;lt;int&amp;gt;q;

    for(int i = 0; i &amp;lt; abbc.size(); i++){
        if(abbc[i] == 'B'){
            b++;
            q.push(i);
        }
        if(abbc[i] == 'C' &amp;amp;&amp;amp; b &amp;gt; 0){
            b--;
            ans++;
            abbc[q.front()] = 'C';
            q.pop();
        }
    }
    for(int i = 0; i &amp;lt; abbc.size(); i++){
        if(abbc[i] == 'A') a++;
        if(abbc[i] == 'B' &amp;amp;&amp;amp; a &amp;gt; 0){
            a--;
            ans++;
        }
    }
    cout &amp;lt;&amp;lt; ans;
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/137</guid>
      <comments>https://eugene-lab.tistory.com/137#entry137comment</comments>
      <pubDate>Sun, 19 Feb 2023 12:31:10 +0900</pubDate>
    </item>
    <item>
      <title>백준 25379(2022 정보올림피아드 고등부 1): 피하자 [C++]</title>
      <link>https://eugene-lab.tistory.com/136</link>
      <description>&lt;pre id=&quot;code_1676770166164&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;algorithm&amp;gt;

using namespace std;
int main()
{
    int n;
    cin &amp;gt;&amp;gt; n;
    int ca[2] = {0};
    for(int i = 0; i &amp;lt; n; i++){
        int x;
        cin &amp;gt;&amp;gt; x;
        ca[x%2]++;
    }
    cout &amp;lt;&amp;lt; min(ca[0], ca[1]);
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;모두 0과 1 로 바꾼후 한쪽으로 밀면 해결된다&lt;/p&gt;</description>
      <category>algorithm/백준</category>
      <category>c++</category>
      <category>정올</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/136</guid>
      <comments>https://eugene-lab.tistory.com/136#entry136comment</comments>
      <pubDate>Sun, 19 Feb 2023 10:29:56 +0900</pubDate>
    </item>
    <item>
      <title>[C++] 백준 7567번 : 그릇</title>
      <link>https://eugene-lab.tistory.com/135</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7567&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;link : https://www.acmicpc.net/problem/7567&lt;/a&gt;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;problem&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;입력 : '(' 또는 ')'&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;출력 : 최종 그릇의 높이&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;solution&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그릇 문자열을 돌면서 전 그릇과 비교한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;code&lt;/h3&gt;
&lt;pre id=&quot;code_1657333771064&quot; class=&quot;cpp&quot; data-ke-language=&quot;cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;

int main()
{
    int h = 10;
    string a;
    cin &amp;gt;&amp;gt; a;
    for(int i = 1; i &amp;lt; a.size(); i++){
        (a[i] == a[i-1]) ? h+=5 : h+=10;
    }
    cout &amp;lt;&amp;lt; h;

}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>7567</category>
      <category>boj</category>
      <category>c++</category>
      <category>백준</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/135</guid>
      <comments>https://eugene-lab.tistory.com/135#entry135comment</comments>
      <pubDate>Sat, 9 Jul 2022 11:29:56 +0900</pubDate>
    </item>
    <item>
      <title>[C++] 프로그래머스 lv2-위장</title>
      <link>https://eugene-lab.tistory.com/134</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;문제 링크 : &lt;a href=&quot;https://programmers.co.kr/learn/courses/30/lessons/42578&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://programmers.co.kr/learn/courses/30/lessons/42578&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1. map 에 옷의 종류와 종류에 있는 옷의 수를 저장한다&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. map 의 값을 모두 1씩 더하고 다 곱해주면 모든 경우의 수가 나온다&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3. 모두 안입는 경우 1개를 빼면 끝&lt;/p&gt;
&lt;pre id=&quot;code_1654303998903&quot; class=&quot;cpp&quot; data-ke-language=&quot;cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;map&amp;gt;
#include &amp;lt;algorithm&amp;gt;

using namespace std;

int solution(vector&amp;lt;vector&amp;lt;string&amp;gt;&amp;gt; clothes) {
    int answer = 1;
    map&amp;lt;string, int&amp;gt; m;
    for(int i = 0; i &amp;lt; clothes.size(); i++){
        m.insert(make_pair(clothes[i][1], 0));
    }
    for(int i = 0; i &amp;lt; clothes.size(); i++) {
        m[clothes[i][1]] += 1;
    }
    for(auto i : m){
        answer *= i.second+1;
    }
    return answer-1;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>algorithm/프로그래머스</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/134</guid>
      <comments>https://eugene-lab.tistory.com/134#entry134comment</comments>
      <pubDate>Sat, 4 Jun 2022 10:01:16 +0900</pubDate>
    </item>
    <item>
      <title>[C++] 프로그래머스 lv2-전화번호 목록</title>
      <link>https://eugene-lab.tistory.com/133</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;문제 링크:&lt;a href=&quot;https://programmers.co.kr/learn/courses/30/lessons/42577&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt; https://programmers.co.kr/learn/courses/30/lessons/42577&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;전화번호부를 정렬한 후 뒤 전화번호가 앞의 전화번호로 시작하는지만 보면 된다.&lt;/p&gt;
&lt;pre id=&quot;code_1653092544440&quot; class=&quot;cpp&quot; data-ke-language=&quot;cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;algorithm&amp;gt;

using namespace std;

bool solution(vector&amp;lt;string&amp;gt; phone_book) {
    sort(phone_book.begin(), phone_book.end());
    for(int i = 0; i &amp;lt; phone_book.size()-1; i++) {
        if (phone_book[i] == phone_book[i+1].substr(0, phone_book[i].size()))
            return false;
    }
    return true;
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>algorithm/프로그래머스</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/133</guid>
      <comments>https://eugene-lab.tistory.com/133#entry133comment</comments>
      <pubDate>Sat, 21 May 2022 09:24:36 +0900</pubDate>
    </item>
    <item>
      <title>[C++]백준 9095번: 1, 2, 3 더하기</title>
      <link>https://eugene-lab.tistory.com/132</link>
      <description>&lt;h3 data-ke-size=&quot;size23&quot;&gt;&lt;b&gt;problem&lt;/b&gt;&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;링크 : &lt;a href=&quot;https://www.acmicpc.net/problem/9095&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/9095&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;입력 : 테스트 케이스 T, T개의 n&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;출력 : 1, 2, 3을 통해 n을 만들 수 있는 경우의 수&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;&lt;b&gt;solution&lt;/b&gt;&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;다이나믹 프로그래밍을 이용해서 푼다(dp[i] = 1, 2, 3 을 이용해 i 를 만들 수 있는 경우의수)&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1. dp[1] = 1, dp[2] = 2, dp[3] = 4 (1 / 1+1, 2 / 1+1+1, 1+2, 2+1, 3)&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2, dp[i] = dp[i-1] + dp[i-2] + dp[i-3]&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. 3 ~ 11 까지&amp;nbsp; 값을 dp에 저장한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;&lt;b&gt;code&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;pre id=&quot;code_1652585553906&quot; class=&quot;cpp&quot; data-ke-language=&quot;cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;


using namespace std;

int main()
{
    int dp[11], t;
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    for(int i = 4; i &amp;lt; 11; i++){
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }

    cin &amp;gt;&amp;gt; t;
    while(t--){
        int n;
        cin &amp;gt;&amp;gt; n;
        cout &amp;lt;&amp;lt; dp[n] &amp;lt;&amp;lt; endl;

    }

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>algorithm/백준</category>
      <category>1</category>
      <category>2</category>
      <category>3</category>
      <category>9095</category>
      <category>boj</category>
      <category>c++</category>
      <category>더하기</category>
      <category>백준</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/132</guid>
      <comments>https://eugene-lab.tistory.com/132#entry132comment</comments>
      <pubDate>Sun, 15 May 2022 12:33:00 +0900</pubDate>
    </item>
    <item>
      <title>[python]백준 1094번: 막대기</title>
      <link>https://eugene-lab.tistory.com/130</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;problem&amp;nbsp;&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제 링크:&amp;nbsp; &lt;a href=&quot;https://www.acmicpc.net/problem/1094&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/1094&amp;nbsp;&amp;nbsp;&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;입력: n&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;출력: 막대기를 자르는 횟수&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;solution&amp;nbsp;&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제 해석&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;길이64의 막대 -&amp;gt; 이진수 범위 00000&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;나누고 버리고 -&amp;gt; 버릴때 1을 표시&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;즉 입력값을 이진수로 변환하는 문제다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;code&lt;/h4&gt;
&lt;pre id=&quot;code_1644385414685&quot; class=&quot;python&quot; data-ke-language=&quot;python&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;x = int(input())
ans = 0
bof2 = []
while x &amp;gt; 0:
    if x % 2 == 1:
        bof2.append(1)
    else:
        bof2.append(0)
    x = x // 2

bof2.reverse()
print(bof2.count(1))&lt;/code&gt;&lt;/pre&gt;</description>
      <category>algorithm/백준</category>
      <category>1094</category>
      <category>boj</category>
      <category>python</category>
      <category>백준</category>
      <category>이진수</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/130</guid>
      <comments>https://eugene-lab.tistory.com/130#entry130comment</comments>
      <pubDate>Mon, 14 Feb 2022 00:56:01 +0900</pubDate>
    </item>
    <item>
      <title>[c++]백준 1916번: 최소비용 구하기</title>
      <link>https://eugene-lab.tistory.com/129</link>
      <description>&lt;h3 data-ke-size=&quot;size23&quot;&gt;problem&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제링크 : &lt;a href=&quot;https://www.acmicpc.net/problem/1916&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/1916&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;입력: 도시의 개수 N, 버스의 개수 M, 버스의 정보(출발지, 도착지, 비용), 출발지점, 도착지점&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;출력: 출발지점에서 도착지점까지의 최소비용&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;solution&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1753번에서 사용한 다익스트라 알고리즘으로 출발 지점부터 모든 정점까지의 거리를 배열에 담은 뒤 배열의 (도착지점-1) 을 출력한다.&lt;/p&gt;
&lt;pre id=&quot;code_1642549913345&quot; class=&quot;c++ arduino&quot; data-ke-language=&quot;c++&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;queue&amp;gt;
#define inf 987654321

using namespace std;
vector&amp;lt;vector&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt;&amp;gt; atob;
vector&amp;lt;int&amp;gt;d;

void dijkstra(int start)
{
    d[start] = 0;
    priority_queue&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; q;
    q.push(make_pair(0, start));
    while (!q.empty()) {
        int now = q.top().second;
        int dis = -q.top().first;
        q.pop();
        if(d[now] &amp;lt; dis)continue;

        for(int i = 0; i &amp;lt; atob[now].size(); i++){
            int next = atob[now][i].second;
            int NextDistance = dis + atob[now][i].first;
            if(NextDistance &amp;lt; d[next]){
                d[next] = NextDistance;
                q.push(make_pair(-NextDistance, next));
            }
        }
    }

}

int main()
{
    int n, m;
    cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; m;
    atob.resize(n);
    d.resize(n, inf);
    for(int i = 0; i &amp;lt; m; i++){
        int n1, n2, l;
        cin &amp;gt;&amp;gt; n1 &amp;gt;&amp;gt; n2 &amp;gt;&amp;gt; l;
        n1--;
        n2--;
        atob[n1].push_back(make_pair(l, n2));
    }
    int s, e;
    cin &amp;gt;&amp;gt; s &amp;gt;&amp;gt; e;
    dijkstra(s-1);

    cout &amp;lt;&amp;lt; d[e-1];
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>algorithm/백준</category>
      <category>1916</category>
      <category>c++</category>
      <category>다익스트라</category>
      <category>백준</category>
      <author>bouble12</author>
      <guid isPermaLink="true">https://eugene-lab.tistory.com/129</guid>
      <comments>https://eugene-lab.tistory.com/129#entry129comment</comments>
      <pubDate>Wed, 19 Jan 2022 09:35:15 +0900</pubDate>
    </item>
  </channel>
</rss>