diff --git a/baekjoon/2745/solution.cpp b/baekjoon/2745/solution.cpp new file mode 100644 index 0000000..74ac32c --- /dev/null +++ b/baekjoon/2745/solution.cpp @@ -0,0 +1,31 @@ +#include +#include + +using namespace std; + +int main() { + string input_num; + int base_num; + int input_size; + int result = 0; + + cin >> input_num >> base_num; + + input_size = input_num.size(); + + for(int i = input_size-1 ; i >=0 ; i--){ + char c = input_num.at(i); + int tmp; + if(isalpha(c)){ + tmp = (tolower(c) - 'a' + 10); + } else { + tmp = c - '0'; + } + // cout << tmp << "*" << pow(base_num, (input_size-i-1)) << endl; + tmp = (tmp * pow(base_num, (input_size-i-1))); + // cout << tmp << endl; + result += tmp; + } + + cout << result; +} \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..7f51ced --- /dev/null +++ b/main.cpp @@ -0,0 +1,2 @@ +#include +