[KR][KR-DEV] Baekjoon 온라인저지 문제풀이 : 12790번

in #kr6 years ago

Baekjoon 온라인저지 문제풀이

VOL.2
2018.07.16 Date | Written by @geunwoong0624

오랜만에 글을 쓰는 @geunwoong0624입니다. 그동안 개인적인 일들을 하면서 지내왔는데 마지막으로 글쓴지 꽤 시간이 흘렀네요. 하루 이틀 안쓰기 시작하니 점점 멀어지는듯 합니다. 다시 성실히 글을 쓰도록 하겠습니다. 오랜만에 글을 쓰는거라 어떤것을 쓸까하다 제가 쉽게 접할 수 있는 알고리즘 문제 풀이로 시작할까합니다. 문제의 이름은 Mini Fantasy War입니다. 문제는 여기에서 확인할 수 있습니다.

summary


  • 플레이어의 기본 능력치가 존재한다(Hp, Mp, 공격력, 방어력)
  • 장비를 통한 수치가 존재한다(Hp, Mp, 공격력, 방어력)
  • 플레이어의 능력치중 Hp와 Mp는 1이상, 공격력은 0이상 이다.(즉, 방어력은 음수가 가능하다)
  • 플레이어의 총전투력은 1 * Hp + 5 * Mp + 2 * 공격력 + 2 * 방어력 로 결정된다

Input
첫줄에는 Test 수가 주어집니다.
다음줄 부터 총 8개의 숫자 (플레이어의 기본능력치, 장비의 능력치) 가 주어집니다.
Output
총전투력을 출력합니다.









Insight


#include <stdio.h>

int main(void) {
    int Test_case;
    scanf("%d", &Test_case);
    for (int i = 0; i < Test_case; i++) {
        //플레이어
        int p_Hp; //체력
        int p_Mp; //마나
        int p_Ap; //공격력
        int p_Vp; //방어력
        //장비
        int Hp; //체력
        int Mp; //마나
        int Ap; //공격력
        int Vp; //방어력
        //최종
        int f_Hp; //체력
        int f_Mp; //마나
        int f_Ap; //공격력
        int f_Vp; //방어력
        int sum = 0; //전투력
        scanf("%d %d %d %d %d %d %d %d", &p_Hp, &p_Mp, &p_Ap, &p_Vp, &Hp, &Mp, &Ap, &Vp);
        //최종능력치 계산
        f_Hp = p_Hp + Hp;
        f_Mp = p_Mp + Mp;
        f_Ap = p_Ap + Ap;
        f_Vp = p_Vp + Vp;
        if (f_Hp < 1) {
            f_Hp = 1;
        }
        if (f_Mp < 1) {
            f_Mp = 1;
        }
        if (f_Ap < 0) {
            f_Ap = 0;
        }
        sum = 1 * f_Hp + 5 * f_Mp + 2 * f_Ap + 2 * f_Vp;
        printf("%d\n", sum);
    }
    return 0;
}

Reference

  1. [KR] Baekjoon 온라인저지 문제풀이 - 1 : 13300번



p.s
해당 게시글은 [이지스팀잇] 마크타운, 고오급 편집팁 (2) - 템플릿 대방출에서 작성된 템플릿으로 작성된 글입니다.
해당 템플릿을 만들어주신 @kyunga 님 감사합니다

Editorial Design by @kyunga
Sort:  

Congratulations @geunwoong0624! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of posts published

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - Play-off for third result


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Hi there! I just upvoted you, I am a semibot that sometimes vote on great content or sometimes just Create useful content. I am helping @cheetah , @FollowForUpvotes , @minnowSupport , @steemgigs , @dropahead #bots and other users right now for making the steem more helpful to new users. Contact me if you want me to follow on your content or comments. If you have any query then please contact me. You can always send me SP or SBD so i can keep helping you indirectly by helping these awesome bots.



Do not forget to Follow @jeevanot, I actually create content as HUMAN.
Random Gift Photo For Your Better Mood: Click It!

안녕하세요, 템플릿을 사용해주셔서 감사합니다. 이제 복붙하지 않으셔도 되요! 업그레이드 버젼이 나왔습니다. 아래 링크에서 확인하실 수 있습니다 :-)

https://steemit.com/kr/@easysteemit/easysteemit-steemit-com-enhancer#comments

Congratulations @geunwoong0624! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 1250 upvotes. Your next target is to reach 1500 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemFest³ - SteemitBoard Contest Teaser
The new Steemfest³ Award is ready!

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @geunwoong0624! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

The Steem community has lost an epic member! Farewell @woflhart!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.030
BTC 59190.13
ETH 3187.58
USDT 1.00
SBD 2.45