문제 링크입니다: https://www.acmicpc.net/problem/6609
6609번: 모기곱셈
입력은 여러 개의 테스트 케이스로 이루어져 있으며 각 테스트 케이스당 한 줄로 주어진다. 각 줄은 7개의 변수인 M, P, L, E, R, S, N이 포함되어 있으며 공백문자로 나누어져 있다. M,P,L은 각각 첫
www.acmicpc.net
간단한 수학 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <sstream> | |
#include <vector> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
string input; | |
while (getline(cin, input)) | |
{ | |
stringstream inputStream(input); | |
int M, P, L, E, R, S, N; | |
inputStream >> M >> P >> L >> E >> R >> S >> N; | |
vector<int> larvas, cocoons, mosquitos; | |
larvas.push_back(L); | |
cocoons.push_back(P); | |
mosquitos.push_back(M); | |
for (int i = 0; i < N; i++) | |
{ | |
P = larvas.back() / R; | |
M = cocoons.back() / S; | |
L = mosquitos.back() * E; | |
larvas.push_back(L); | |
cocoons.push_back(P); | |
mosquitos.push_back(M); | |
} | |
int result = mosquitos.back(); | |
cout << result << "\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 6779번 Who Has Seen The Wind (0) | 2021.06.04 |
---|---|
백준 6696번 Too Much Water (0) | 2021.06.03 |
백준 6491번 Perfection (0) | 2021.06.03 |
백준 3602번 iChess (0) | 2021.06.03 |
백준 6437번 Golf (2) | 2021.06.01 |