본문 바로가기
코딩테스트/LV. 0

LV. 0 :: 개미 군단

by KUROMI98 2023. 1. 20.

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

function solution(hp) {
    var answer = 0;
    ant1 = Math.floor(hp/5);
    ant2 = Math.floor((hp%5)/3);
    ant3 = Math.floor(((hp%5)%3));
    answer = ant1+ant2+ant3;
    return answer;
}

230525 python

def solution(hp):
    return hp//5 + hp%5//3 + hp%5%3

230915 C++

#include <string>
#include <vector>

using namespace std;

int solution(int hp) { 
int ant1 = hp/5;
int ant2 = (hp%5)/3;
int ant3 = ((hp%5)%3);
    return ant1+ant2+ant3;
}

'코딩테스트 > LV. 0' 카테고리의 다른 글

LV. 0 :: 주사위의 개수  (0) 2023.01.20
LV. 0 :: 세균 증식  (0) 2023.01.20
LV. 0 :: 최댓값 만들기 1  (0) 2023.01.20
LV. 0 :: 문자열 뒤집기  (0) 2023.01.20
LV. 0 :: 배열 자르기  (0) 2023.01.20

댓글