알고리즘

[알고리즘] 백준 10829 - 이진수 변환 (C++)

blueberrysoda 2024. 11. 8. 23:45

[문제 링크] : https://www.acmicpc.net/problem/10829

#include <iostream>
using namespace std;

void solve(long long n){
    if(n == 0 || n == 1){
        cout << n;
    }
    else{
        solve(n / 2);
        cout << n % 2;
    }
    return;
}

int main(){
    long long N;
    cin >> N;

    solve(N);
    cout << "\n";
    return 0;
}