알고리즘/BOJ

백준 14614번 Calculate!

꾸준함. 2019. 1. 29. 03:14

문제 링크입니다: https://www.acmicpc.net/problem/14614


이산수학을 배웠다면 XOR의 특성을 알기 때문에 쉽게 풀 수 있는 문제였습니다.


*C의 범위가 매우 크기 때문에 C를 string 형태로 입력받아야합니다.


#include <iostream>

#include <string>

using namespace std;

 

int main(void)

{

        ios_base::sync_with_stdio(0);

        cin.tie(0);

        int A, B;

        string C;

        cin >> A >> B >> C;

 

        if ((C[C.length()-1] - '0') % 2)

                 cout << (A^B) << "\n";

        else

                 cout << A << "\n";

        return 0;

}


개발환경:Visual Studio 2017


지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형

'알고리즘 > BOJ' 카테고리의 다른 글

백준 9020번 골드바흐의 추측  (0) 2019.01.30
백준 2018번 수들의 합 5  (0) 2019.01.29
백준 2143번 두 배열의 합  (0) 2019.01.27
백준 2632번 피자 판매  (6) 2019.01.27
백준 3020번 개똥벌레  (8) 2019.01.27