목록구현 (29)
정화 코딩

https://www.acmicpc.net/problem/12873 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector a(n); for (int i = 0; i 태그는 큐인데 나는 그냥 vector와 erase 함수를 사용했다. 근데 여기서 주의할 점이 두 가지가 있다. (내가 여러번 틀린 이유...)1. cmath에 있는 pow(i, 3)를 사용하면 값이 의도대로 나오지 않을 수 있다. pow의 반환값이 double이라서 int로 바꾸는 과정에서 문제가 생길 수 있기 때문이다. 그래서 ..

https://www.acmicpc.net/problem/30885 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); list> li; int n; cin >> n; for (int i = 1; i > x; li.emplace_back(x, i); } while (li.size() > 1) { for (auto i = li.begin(); i != li.end(); i++) { long long a = i->first; // 현재 가리키고 있는 미생물의 크기 ..

https://www.acmicpc.net/problem/31870 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector a(n); for (int i = 0; i > a[i]; int ans = 1000000000; for (int k = 0; k at = a; int cnt = 0; for (int i = n - 1; i > 0; i--) { if (i == k) { reverse(at.b..

https://www.acmicpc.net/problem/16677 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; int n; cin >> s >> n; int sn = s.size(); double ans = 0; string anss = "No Jam"; while (n--) { string a; double g; cin >> a >> g; int an = a.size(); int cnt = 0; int idx1 = 0; ..

https://www.acmicpc.net/problem/1308 #include using namespace std;bool isleap(int n) { if (n % 4 == 0) { if (n % 100 == 0) { if (n % 400 == 0) return true; else return false; } return true; } return false;}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, ..

https://www.acmicpc.net/problem/10174 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tn; cin >> tn; while (tn--) { string s; getline(cin, s); int n = s.length(); for (int i = 0; i = 'A' && s[i] 공백이 들어올 수 있기 때문에 string으로 받는 것이 아니라 한 줄 전체를 받아야 한다.C++ 한 줄 입력받기: getline(cin, s);근데 위의 코드를 돌리면 반복문이 n-1번..

https://www.acmicpc.net/problem/9328 #include #include #include using namespace std;int dx[] = {1, -1, 0, 0};int dy[] = {0, 0, 1, -1};int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc; cin >> tc; while (tc--) { int h, w; cin >> h >> w; vector m(h); vector> chk(h, vector(w, false)); vector open(26, false); queue>..

솔브닥 class 4+ 풀고 있었는데 거기에 피보나치 수 6 문제가 있길래 이참에 피보나치 수 문제를 쭉 풀어볼까 한다. 피보나치 수 (백준 2747번)https://www.acmicpc.net/problem/2747 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector fib(n + 1); fib[0] = 0; fib[1] = 1; for (int i = 2; i 바텀업 dp로 풀었다. (AC) 피보나치 수 2 (백준 2748번)https://www.acmicpc.net/..