728x90
https://www.acmicpc.net/problem/1592
#include <iostream>
#include <tuple>
#include <vector>
#include <map>
#include <queue>
using namespace std;
int main() {
int numOfPeople, m, l;
cin >> numOfPeople >> m >> l;
vector<int> count(numOfPeople);
int currentPerson = 0;
count[currentPerson] = 1;
int ballTossCount = 0;
while (true) {
ballTossCount++;
if (count[0] % 2 == 0) {
currentPerson = (currentPerson - l + numOfPeople) % numOfPeople;
}
else {
currentPerson = (currentPerson + l) % numOfPeople;
}
count[currentPerson]++;
if (count[currentPerson] == m) break;
}
cout << ballTossCount;
return 0;
}
728x90
'알고리즘 문제' 카테고리의 다른 글
[백준] 4659번 비밀번호 발음하기 (0) | 2020.02.12 |
---|---|
[백준] 4690번 완전 세제곱 (0) | 2020.02.12 |
[백준] 1526번 가장 큰 금민수 (0) | 2020.02.12 |
[백준] 9237번 이장님 초대 (0) | 2020.02.12 |
[백준] 1991번 트리 순회 (0) | 2020.02.12 |