# Link

https://www.acmicpc.net/problem/5671

 

5671번: 호텔 방 번호

선영이는 집 호수에 반복되는 숫자가 있는 경우에는 그 집에 사는 사람에게 불운이 찾아온다고 믿는다. 따라서, 선영이는 838호나 1004호와 같이 한 숫자가 두 번 이상 들어있는 집에는 절대 살지

www.acmicpc.net

 

 

# Code - C++

//
//  BOJ
//  ver.C++
//
//  Created by GGlifer
//
//  Open Source

#include <iostream>
#include <set>

using namespace std;

#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))

// Set up : Definitions
/* None */

// Set up : Global Variables
/* None */

// Set up : Functions Declaration
/* None */


int main()
{
    // Set up : I/O
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Set up : Input
    int N, M;
    while (cin >> N >> M) {

        // Process
        int ans = 0;
        for (int i=N; i<=M; i++) {
            string s = str(i);
            if (len(s) == size(set(s.begin(), s.end()))) {
                ans++;
            }
        }

        // Control : Output
        cout << ans << endl;
    }
}

// Helper Functions
/* None */

 

 

지적, 조언, 첨언 모두 환영합니다!!!

# Link

https://www.acmicpc.net/problem/10699

 

10699번: 오늘 날짜

서울의 오늘 날짜를 출력하는 프로그램을 작성하시오.

www.acmicpc.net

 

 

# Code - C++

//
//  BOJ
//  ver.C++
//
//  Created by GGlifer
//
//  Open Source

#include <iostream>
#include <iomanip>
#include <ctime>

using namespace std;

#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))

// Set up : Definitions
const int HOUR = 60 * 60;

// Set up : Global Variables
/* None */

// Set up : Functions Declaration
/* None */


int main()
{
    // Set up : I/O
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Set up : Input
    /* None */

    // Process
    time_t utc = time(nullptr);
    time_t kor = utc + 9 * HOUR;
    tm *info = gmtime(&kor);

    // Control : Output
    cout << put_time(info, "%Y-%m-%d") << endl;
}

// Helper Functions
/* None */

 

 

지적, 조언, 첨언 모두 환영합니다!!!

# Link

https://www.acmicpc.net/problem/11657

 

11657번: 타임머신

첫째 줄에 도시의 개수 N (1 ≤ N ≤ 500), 버스 노선의 개수 M (1 ≤ M ≤ 6,000)이 주어진다. 둘째 줄부터 M개의 줄에는 버스 노선의 정보 A, B, C (1 ≤ A, B ≤ N, -10,000 ≤ C ≤ 10,000)가 주어진다. 

www.acmicpc.net

 

 

# Code - C++

//
//  BOJ
//  ver.C++
//
//  Created by GGlifer
//
//  Open Source

#include <iostream>
#include <algorithm>

using namespace std;

#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))

// Set up : Definitions
typedef long long ll;
const ll INF = 998877665544332211LL;
struct Edge { int a, b, c; };

// Set up : Global Variables
/* None */

// Set up : Functions Declaration
/* None */


int main()
{
    // Set up : I/O
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Set up : Input
    int N, M;
    cin >> N >> M;
    Edge E[M];
    for (int i=0; i<M; i++)
        cin >> E[i].a >> E[i].b >> E[i].c;

    // Process
    ll dp[N+1];
    fill(dp+1, dp+(N+1), INF);
    dp[1] = 0;

    for (int i=0; i<N-1; i++) {
        for (auto [a, b, c] : E) {
            if (dp[a] == INF) continue;
            if (dp[b] > dp[a]+c) {
                dp[b] = dp[a]+c;
            }
        }
    }

    bool isInf = false;
    for (auto [a, b, c] : E) {
        if (dp[a] == INF) continue;
        if (dp[b] > dp[a]+c) {
            isInf = true;
            break;
        }
    }

    // Control : Output
    if (isInf)
        cout << -1 << endl;
    else {
        for (int i=2; i<=N; i++) {
            cout << ((dp[i] == INF) ? -1 : dp[i]) << endl;
        }
    }
}

// Helper Functions
/* None */

 

 

지적, 조언, 첨언 모두 환영합니다!!!

# Tag

- ps

- boj

- c++ / java / python

+ Recent posts