반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> #include <cstring> using namespace std; int b,ans; char a[10000]; int main() { cin >> a >> b; for (int i = 0; i < strlen(a); i++) { int tmp = 1; for (int j = 0; j < i; j++) tmp *= b; if ('A' <= a[strlen(a)-i-1] && a[strlen(a)-i-1] <= 'Z')//가장 마지막 쪽이 알파벳이면 { int k = 10; k += a[strlen(a)-i-1] - 65; ans += tmp * k; } else ans += tmp * (a[strlen(a)-i-1]-'0'); } cout << ans << '\n'; } | cs |
'Algorithm' 카테고리의 다른 글
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10867번:중복 빼고 정렬하기 답 (0) | 2017.03.26 |
---|---|
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2042번:구간 합 구하기 답 (0) | 2017.03.24 |
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2774번:아름다운 수 답 (0) | 2017.03.21 |
(C++) - 백준(BOJ) 1356번 : 유진수 답 (0) | 2017.03.21 |
(C++) - 백준(BOJ) 1940번 : 주몽 답 (0) | 2017.03.21 |