diff --git a/atcoder/beginner_contests/250/a.cpp b/atcoder/beginner_contests/250/a.cpp new file mode 100644 index 0000000..0413fae --- /dev/null +++ b/atcoder/beginner_contests/250/a.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int h, w, r, c; + + cin >> h >> w >> r >> c; + + int result = 0; + if(h > 1){ + result++; + } + + if(w > 1){ + result++; + } + + if(r != 1 && r != h){ + result++; + } + + if(c != 1 && c != w){ + result++; + } + + cout << result; + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/b.cpp b/atcoder/beginner_contests/250/b.cpp new file mode 100644 index 0000000..d018c10 --- /dev/null +++ b/atcoder/beginner_contests/250/b.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, a, b; + cin >> n >> a >> b; + + bool color = true; + + for(int vertical_tiles = 0; vertical_tiles < n; ++vertical_tiles){ + for(int vertical_length = 0; vertical_length < a; ++vertical_length){ + for(int horizontal_tiles = 0; horizontal_tiles < n; ++horizontal_tiles){ + for(int horizontal_length = 0; horizontal_length < b; ++horizontal_length){ + cout << (color ? "." : "#"); + } + color = !color; + } + cout << '\n'; + if(n % 2 != 0){ + color = !color; + } + } + color = !color; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/c.cpp b/atcoder/beginner_contests/250/c.cpp new file mode 100644 index 0000000..bac634a --- /dev/null +++ b/atcoder/beginner_contests/250/c.cpp @@ -0,0 +1,51 @@ +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, q; + cin >> n >> q; + + // Denoting what ball is on the ith position + vector numberBall(n); + // Denoting where the ith ball is + vector ballPosition(n); + + for(int i = 0; i < n; ++i){ + numberBall[i] = i; + ballPosition[i] = i; + } + + for(int j = 0; j < q; ++j){ + int xq; + cin >> xq; + xq--; + + int x_pos = ballPosition[xq], y_pos, yq; + + if(x_pos != n - 1){ + y_pos = x_pos + 1; + yq = numberBall[y_pos]; + + swap(numberBall[x_pos], numberBall[y_pos]); + swap(ballPosition[xq], ballPosition[yq]); + } else{ + y_pos = x_pos - 1; + yq = numberBall[y_pos]; + + swap(numberBall[x_pos], numberBall[y_pos]); + swap(ballPosition[xq], ballPosition[yq]); + } + } + + for(int i = 0; i < n; ++i){ + cout << numberBall[i] + 1 << " "; + } cout << endl; + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/d.cpp b/atcoder/beginner_contests/250/d.cpp new file mode 100644 index 0000000..c41b48d --- /dev/null +++ b/atcoder/beginner_contests/250/d.cpp @@ -0,0 +1,66 @@ +#include + +using namespace std; + +typedef unsigned long long ull; + +vector primes(ull maxPrime){ + vector p(maxPrime + 1, true); + + for(ull i = 2; i <= sqrt(maxPrime + 1); ++i){ + if(p[i]){ + for(ull j = i * 2; j < maxPrime + 1; j += i){ + p[j] = false; + } + } + } + + vector result; + for(ull i = 2; i < maxPrime + 1; ++i){ + if(p[i]){ + result.push_back(i); + } + } + + return result; +} + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + ull n; + cin >> n; + + ull topPrime = ceil(cbrt(ceil(n / 2))); + auto ps = primes(topPrime); + + ull result = 0; + + if(ps.size() < 2){ + cout << result << endl; + cout << flush; + return 0; + } + + for(size_t i = 1; i < ps.size(); ++i){ + ull q = ps[i]; + + for(size_t j = 0; j < i; ++j){ + ull p = ps[j]; + ull k = p * q * q * q; + + if(k > n){ + break; + } + result++; + } + } + + cout << result << endl; + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/e.cpp b/atcoder/beginner_contests/250/e.cpp new file mode 100644 index 0000000..e866788 --- /dev/null +++ b/atcoder/beginner_contests/250/e.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, q; + cin >> n; + + vector a(n), b(n); + + for(int i = 0; i < n; ++i){ + cin >> a[i]; + } + for(int i = 0; i < n; ++i){ + cin >> b[i]; + } + + cin >> q; + for(int j = 0; j < q; ++j){ + int x, y; + cin >> x >> y; + + set a_set(a.begin(), a.begin() + x); + set b_set(b.begin(), b.begin() + y); + + cout << (a_set == b_set ? "Yes" : "No") << '\n'; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/ex.cpp b/atcoder/beginner_contests/250/ex.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/atcoder/beginner_contests/250/ex.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +void test_case(int tc){ + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/f.cpp b/atcoder/beginner_contests/250/f.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/atcoder/beginner_contests/250/f.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +void test_case(int tc){ + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/atcoder/beginner_contests/250/g.cpp b/atcoder/beginner_contests/250/g.cpp new file mode 100644 index 0000000..0c03bec --- /dev/null +++ b/atcoder/beginner_contests/250/g.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +void test_case(int tc){ + +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file