본문 바로가기

BOJ/C++

(202)
다리놓기 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #include #include using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); //최대 n개 만큼만 다리를 지을 수 있다. int t; cin >> t; while (t--) { int n, m; cin >> n >> m; if (n == m) { cout
소수합 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #include #include #define MAXX 4000001 using namespace std; bool isPrime[MAXX]; int prime[MAXX]; void findPrime(int n) { for (int i = 2; i n; for (int i = 2; i
암호제작 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #include #include #include #define MAXX 1000001 using namespace std; typedef long long ll; bool isPrime[MAXX]; void findPrime(int k) { for (int i = 2; i > k; for (int i = 2; i
1 #include #include #include using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; while (1) { cin >> n; if (cin.eof()) break; int res = 1; int cnt = 1; while (1) { if (res % n == 0) { break; } res = res * 10 + 1; res %= n; cnt++; } cout
보이는 점 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 #include #include #include using namespace std; bool visited[1001][1001]; int n; bool check(int x, int y) { cout
서로소 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 29 30 31 32 33 34 35 36 37 38 #include using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n; while (1) { cin >> n; if (!n) break; //소인수분해한다. ll tmp = n; ll res = n; for (ll i = 2; i*i 1) res -= res / n; cout
내려가기 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 #include #include #include using namespace std; int map[100001][3]; int n; int dy[3] = { -1,0,1 }; int min_res = 987654321, max_res = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i map[i][j]; } } int max_dp[2][3] = {{0}}, min_..
부분구간의 합 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 #include #include #include using namespace std; typedef long long ll; ll sum(vector &tree, int nod..