본문 바로가기
SWEA

[SWEA] 11387. 몬스터 사냥

by 콩순이냉장고 2021. 8. 14.

문제 URL : https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AXb6LR76vCcDFARR&categoryId=AXb6LR76vCcDFARR&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

문제 접근법 : 

 

반복문으로 다 더하는것도 좋지만 수학적으로 공식을 유도해내는게 더 좋은 경험이라고 생각합니다.

 

소스코드 : 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
long long d, n, l;
void input() {
    cin >> d >> l >> n;
}
void solve() {
    cout << (d * n) + ((d * l * n * (n - 1)) / 200<< "\n";
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int test;
    cin >> test;
    for (int i = 1; i <= test; i++) {
        input();
        cout << "#" << i << " ";
        solve();
    }
}
cs

궁금한점 혹은 모르는점 논리적인 오류등 어떤 질문이든 댓글은 언제나 환영입니다.