목록CodingTestTraining/BaekJoon(Basic) (12)
승쨩개발공부
#include #include #include #include using namespace std;int n;int ret = -1;int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = n / 5; i >= 0; --i) // 5로나눈 최대값 { int rest = n - (5 * i); // 5로 나눈 나머지 if (rest % 3 == 0) // 3으로 나누어질떄 { ret = i + (rest / 3); break; } } cout
#include #include #include #include using namespace std;int n;vector v;vector ret_v;void dfs(int here){ if (ret_v.size() == 6) { for (const int& i : ret_v) { cout > n; if (n == 0) break; for (int i = 0; i > a; v.push_back(a); } dfs(0); cout
#include #include #include #include using namespace std;int n, k;int vis[100005];int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; queue q; vis[n] = 1; q.push(n); while (q.size()) { int now = q.front(); q.pop(); for (int next : {now + 1, now - 1, now * 2}) { if (next 100000) continue; if (vis[next]) continue; q.push(next); vis[next] = vis[now] + 1; } } cout
#include #include #include #include using namespace std;int n, m, k;vector v[1005];bool vis[1005];queue q;void bfs(int here){ vis[here] = true; q.push(here); while (q.size()) { int front = q.front(); q.pop(); cout > n >> m >> k; for (int i = 0; i > a >> b; v[a].push_back(b); v[b].push_back(a); } for (int i = 1; i 1) { sort(v[i].begin(), v[i].end()); } } dfs(k); fill(&vis[0], &vis[0] +..
#include using namespace std;#include #include #include #include #include int n;int a[105][105];bool vis[105][105];int h = 1; // 높이int dy[4] = {-1,0,1,0};int dx[4] = { 0,1,0,-1 };int ret = 0;void dfs(int y, int x, int h){ vis[y][x] = true; for (int i = 0; i ny || 0 > nx || ny >= n || nx >= n) continue; if (vis[ny][nx] || h >= a[ny][nx]) continue; dfs(ny, nx, h); }}int main(){ ios::sync_with_s..
0. 수학적 귀납법내가 재귀를 풀떄마다 절차지향적으로 항상 생각했는데, 이젠 수학적 귀납법으로 생각을 해야한다.도미노가있다 그러면 절차지향적 사고와 수학적 귀납법 사고를 생각해보자 1) 절차 지향적 사고1번 도미노가 쓰러지면 2번 도미노도 쓰러지고 2번 도미노가 쓰러지면 3번 도미노도 쓰러진다.1 -> 2 -> 3 -> 4 -> .... 이런식으로 모든 도미노가 쓰러진다 이건 절차지향적인 생각이다. 2) 수학적 귀납법 사고1번 도미노가 쓰러진다 K번 도미노가 쓰러지면 K + 1번 도미노도 쓰러진다.이것이 수학적 귀납법 사고이다. 1. 문제 설명A^B % C (A^B mod C) 를 구하는건데 입력 조건을 보면 A,B,C모두 최대범위가 int의 최대 범위이다즉 약 21억^21억을 한 변수에 담을 수 있을까..