Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- XR Interaction Toolkit
- 시뮬레이션
- 다익스트라
- 정렬
- Team Fortress 2
- DFS
- 문자열
- 투 포인터
- 브루트포스
- ue5
- 자료구조
- 다이나믹 프로그래밍
- 구현
- 유니티
- VR
- 백트래킹
- 그래프
- Unreal Engine 5
- 우선순위 큐
- 수학
- 알고리즘
- BFS
- 트리
- 그리디 알고리즘
- 유니온 파인드
- 재귀
- 스택
- 백준
- c++
- 누적 합
Archives
- Today
- Total
1일1알
백준 3060번 욕심쟁이 돼지 C++ 본문
https://www.acmicpc.net/problem/3060
3060번: 욕심쟁이 돼지
입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터는 두 줄로 구성되어 있고, 첫째 줄에는 하루에 배달되는 사
www.acmicpc.net
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
vector<int64> lastV(6);
vector<int64> currV(6);
int t;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
while (t--) {
int64 n;
cin >> n;
for (int i = 0; i < 6; i++) cin >> lastV[i];
int day = 1;
while (true) {
int64 sum = 0;
for (int i = 0; i < 6; i++) sum += lastV[i];
if (sum > n) break;
for (int i = 0; i < 6; i++) {
int64 currVal = lastV[i];
currVal += lastV[(i + 1) % 6];
currVal += lastV[(i + 3) % 6];
currVal += lastV[(i + 5) % 6];
currV[i] = currVal;
}
for (int i = 0; i < 6; i++) lastV[i] = currV[i];
day++;
}
cout << day << "\n";
}
}
'알고리즘' 카테고리의 다른 글
백준 17829번 222-풀링 C++ (0) | 2023.05.05 |
---|---|
백준 2508번 사탕 박사 고창영 C++ (0) | 2023.05.04 |
백준 2799번 블라인드 C++ (0) | 2023.05.02 |
백준 4108번 지뢰찾기 C++ (0) | 2023.04.30 |
백준 23843번 콘센트 C++ (0) | 2023.04.29 |