https://dev-repository.tistory.com/48

'C & C++ > SW Expert Academy' 카테고리의 다른 글

SWEA 1284 - 수도 요금 경쟁  (0) 2018.04.28
SWEA 1285 - 아름이의 돌 던지기  (0) 2018.04.28
SWEA 1928 - Base64 Decoder  (0) 2018.04.28
SWEA 1940 - 가랏! RC카!  (0) 2018.04.28
SWEA 1945 - 간단한 소인수분해  (0) 2018.04.28

문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PR4DKAG0DFAUq


문제의 저작권은 SW Expert Academy에 있습니다.



#include <iostream>
 
using namespace std;
 
char decoding(char temp) {
    if(temp >= 'A' & temp <= 'Z') {
        temp = temp - 'A';
    } else if(temp >= 'a' & temp <= 'z') {
        temp = temp - 'a' + 26;
    } else if(temp >= '0' & temp <= '9') {
        temp = temp - '0' + 52;
    } else if(temp == '+') {
        temp = 62;
    } else {
        temp = 63;    
    }
    return temp;
}
 
int main(void) {
    int T;
    cin >> T;
 
    for(int t_case=0; t_case<T; t_case++) {
        string input, output = "";
        char temp;
        cin >> input;
 
        for(int i=0; i<input.length()/4; i++) {
            temp = decoding(input.at(i*4))*4 + decoding(input.at(i*4+1))/16;
            output += temp;
            temp = (decoding(input.at(i*4+1))%16)*16 + (decoding(input.at(i*4+2))/4);
            output += temp;
            temp = (decoding(input.at(i*4+2))%4)*64 + decoding(input.at(i*4+3));
            output += temp;
        }
        cout << "#" << t_case+1 << " " << output << "\n";
    }
 
    return 0;
}
cs

문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PjMgaALgDFAUq


문제의 저작권은 SW Expert Academy에 있습니다.



#include <iostream>
 
using namespace std;
 
int main(void) {
    int T, N, CMD, delta;
    cin >> T;
 
    for(int t_case=0; t_case<T; t_case++) {
        int speed=0, distance = 0;
 
        cin >> N;
        for(int i=0; i<N; i++) {
            cin >> CMD;
            switch(CMD) {
                case 0:
                    distance += speed;
                    break;
                case 1:
                    cin >> delta;
                    speed += delta;
                    distance += speed;
                    break;
                case 2:
                    cin >> delta;
                    speed -= delta;
                    if(speed < 0)
                        speed = 0;
                    distance += speed;
                    break;
            }
        }
 
        cout << "#" << t_case+1 << " " << distance << "\n";
    }
 
    return 0;
}
cs

'C & C++ > SW Expert Academy' 카테고리의 다른 글

SWEA 1288 - 새로운 불면증 치료법  (0) 2018.04.28
SWEA 1928 - Base64 Decoder  (0) 2018.04.28
SWEA 1945 - 간단한 소인수분해  (0) 2018.04.28
SWEA 1946 - 간단한 압축 풀기  (0) 2018.04.28
SWEA 1948 - 날짜 계산기  (0) 2018.04.28

문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Pl0Q6ANQDFAUq


문제의 저작권은 SW Expert Academy에 있습니다.



#include <iostream>
 
using namespace std;
 
int main(void) {
    int T, N, cnt[5], num[5= {235711};
    cin >> T;
 
    for(int t_case=0; t_case<T; t_case++) {
        cin >> N;
 
        for(int i=0; i<5; i++) {
            cnt[i] = 0;
            while(N%num[i] == 0) {
                cnt[i]++;
                N /= num[i];
            }
        }
 
        cout << "#" << t_case+1;
        for(int i=0; i<5; i++)
            cout << " " << cnt[i];
        cout << "\n";
    }
 
    return 0;
}
cs

'C & C++ > SW Expert Academy' 카테고리의 다른 글

SWEA 1928 - Base64 Decoder  (0) 2018.04.28
SWEA 1940 - 가랏! RC카!  (0) 2018.04.28
SWEA 1946 - 간단한 압축 풀기  (0) 2018.04.28
SWEA 1948 - 날짜 계산기  (0) 2018.04.28
SWEA 1954 - 달팽이 숫자  (0) 2018.04.28

문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PmkDKAOMDFAUq


문제의 저작권은 SW Expert Academy에 있습니다.



#include <iostream>
 
using namespace std;
 
int main(void) {
    int T, N;
    cin >> T;
 
    for(int t_case=0; t_case<T; t_case++) {
        cin >> N;
        char c[N];
        int k[N];
 
        for(int i=0; i<N; i++) {
            cin >> c[i];
            cin >> k[i];
        }
 
        cout << "#" << t_case+1 << "\n";
        int cutLine=0;
        for(int i=0; i<N; i++) {
            while(k[i] != 0) {
                cout << c[i];
                k[i]--;
                if(cutLine++ == 9) {
                    cout << "\n";
                    cutLine = 0;
                }
            }
        }
        cout << "\n";
    }
 
    return 0;
}
cs

'C & C++ > SW Expert Academy' 카테고리의 다른 글

SWEA 1940 - 가랏! RC카!  (0) 2018.04.28
SWEA 1945 - 간단한 소인수분해  (0) 2018.04.28
SWEA 1948 - 날짜 계산기  (0) 2018.04.28
SWEA 1954 - 달팽이 숫자  (0) 2018.04.28
SWEA 1959 - 두 개의 숫자열  (0) 2018.04.28

+ Recent posts