Codeforces - 1660A - Vasya and Coins

HoJeong Im·2022년 9월 11일
0

Codeforces

목록 보기
10/13

개요

https://codeforces.com/problemset/problem/1660/A

  • 1, 2원의 가치를 가지는 동전으로 만들 수 없는 최소 양의 값을 구하는 문제입니다.

  • 1원의 가치를 가지는 동전이 없으면 1이 만들 수 없는 최소 양의 값

  • 나머지의 경우는 2원의 가치 동전의 개수 * 2원의 가치 + 1원의 가치 동전의 개수 + 1이 답이 됩니다.

코드

#include <iostream>

using namespace std;

int main() {

    int T;

    cin >> T;

    for(int i = 0 ; i < T ; i++){

        int a, b;

        cin >> a >> b;

        if(a == 0){
            cout << 1 << endl;
        }
        else {
            cout << (2*b + a + 1) << endl;
        }

    }




    return 0;
}
profile
꾸준함이 제일 빠른 길이었다

0개의 댓글