[C++][백준 10953] A+B - 6

PublicMinsu·2025년 8월 14일

문제

https://www.acmicpc.net/problem/10953

접근 방법

A와 B가 콤마로 구분된 점을 활용하면 됩니다.

코드

#include <iostream>
using namespace std;
int T;
string str;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> T;

    while (T--)
    {
        cin >> str;

        cout << (str[0] - '0' + str[2] - '0') << "\n";
    }
    return 0;
}

풀이

A와 B가 0보다 크고 10보다 작기에 1자리씩만 차지한다는 것을 알 수 있습니다. 0번째와 2번째를 파싱하면 됩니다.

profile
연락 : publicminsu@naver.com

0개의 댓글