[프로그래머스/C++]Lv.0 - 종이 자르기

YH J·2023년 4월 17일
0

프로그래머스

목록 보기
2/168

문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/120922

내 풀이

규칙을 생각해 보았다. 가로의 길이 x 세로의 길이 - 1이 규칙이였다.

내 코드

#include <string>
#include <vector>

using namespace std;

int solution(int M, int N) {
    int answer = 0;
    answer = M * N - 1;
    return answer;
}

다른 사람의 풀이

#include <string>
#include <vector>

using namespace std;

int solution(int M, int N) {
    return M*N-1;
}

다른 사람의 풀이 해석

그냥 바로 return 해주었다.

profile
게임 개발자 지망생

0개의 댓글