코딩테스트/프로그래머스 - LV 0
[프로그래머스] 주사위 게임 1
웅드
2024. 1. 30. 17:06
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(int a, int b) {
int answer = 0;
if(a % 2 == 1 && b % 2 == 1) return a*a + b*b;
else if(a % 2 == 1 || b % 2 == 1) return 2*(a+b);
else return abs(a-b);
}
반응형