목록전체 글 (191)
정화 코딩
https://www.acmicpc.net/problem/4673 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool sn[10001]; fill_n(sn, 10001, true); for (int i = 1; i 0) { ans += tmp % 10; tmp = tmp / 10; } if (ans C++에서 초기화를 하려면 fill_n(sn, 10001, true); 이렇게 해야 한다. 끙.. 맨날 벡터만 써서 몰랐네. (정답)
#include #include #include #include using namespace std;string str;int n;string res;bool fin = false;vector a;vector chk;void dfs(int idx) { if (fin) { return; } if (idx == n) { if (res > str) { for (char c: res) { cout > str; res = str.substr(); n = str.size(); chk = vector(n); for (char c: str) { a.push_back(c - '0'); } ..
https://www.acmicpc.net/problem/1166 #include #include typedef long long ll;typedef long double ld;using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, l, w, h; cin >> n >> l >> w >> h; ld li = 0; ld ri = l + 1; for (int i = 0; i 실수 이분 탐색 문제는 처음 풀어봤다. (정답)우선, 오차는 10^(-9)까지 허용한다고 하니 cout li, ri, mi 전부 실수로 정의하되, 이분 탐색 계산할 때는 정수로 계산한..
https://www.acmicpc.net/problem/5430 #include #include #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 func; cin >> func; int n; cin >> n; string str; cin >> str; string tmp; deque deq; for (char c: str) { if (c =..
https://www.acmicpc.net/problem/25046 #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> s(n, vector(n)); for (int i = 0; i > s[i][j]; } } int bm; // rows seleted by minwoo int maxi = 1 > 1; } // if jongjin select this col -> jongjin's score = on ..
https://www.acmicpc.net/problem/3541 #include #include using namespace std;int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y);}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int mina = INT_MAX; while (m--) { int u, d; cin >> u >> d; int gcdt = gcd(u, d); // lcm = u * d / gcd ..
https://www.acmicpc.net/problem/17433 #include #include using namespace std;int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y);}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { cin >> n; vector num(n); vector dif(n - 1); bool inf = true; for (int i = 0; i > num[i]; ..
https://www.acmicpc.net/problem/1684 #include #include #include using namespace std;int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y);}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector num(n); vector dif(n - 1); for (int i = 0; i > num[i]; if (i == 0) continue; dif[i - 1] = abs(num[i] - num[i -..