diff --git a/storage/zeta/cpp/completed/10816.cpp b/storage/zeta/cpp/completed/10816.cpp new file mode 100644 index 0000000..55a6828 --- /dev/null +++ b/storage/zeta/cpp/completed/10816.cpp @@ -0,0 +1,42 @@ +#include +#include + +using namespace std; + +void fastio() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); +} + +int main() { + fastio(); + int n; + cin >> n; + map 상근이카드; + + int x; + for (auto i = 0; i < n; i++) { + cin >> x; + auto pos = 상근이카드.find(x); + if (pos == 상근이카드.end()) { + 상근이카드[x] = 1; + } else { + pos->second++; + } + } + + int m; + cin >> m; + + for (auto i = 0; i < m; i++) { + cin >> x; + auto pos = 상근이카드.find(x); + if (pos == 상근이카드.end()) { + cout << "0 "; + } else { + cout << pos->second << " "; + } + } + cout << "\n"; +} \ No newline at end of file diff --git a/storage/zeta/cpp/completed/1764.cpp b/storage/zeta/cpp/completed/1764.cpp new file mode 100644 index 0000000..86696a8 --- /dev/null +++ b/storage/zeta/cpp/completed/1764.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; + +void fastio() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); +} + +int main() { + fastio(); + + int n, m; + + cin >> n >> m; + + auto 듣도못한사람 = new set(); + auto 보도못한사람 = new set(); + for (auto i = 0; i < n; i++) { + string name; + cin >> name; + 듣도못한사람->insert(name); + + + } + + for (auto j = 0; j < m; j++) { + string name; + cin >> name; + 보도못한사람->insert(name); + } + + auto 듣도보도못한사람 = new vector(); + set_intersection( + 듣도못한사람->begin(), 듣도못한사람->end(), + 보도못한사람->begin(), 보도못한사람->end(), + back_inserter(*듣도보도못한사람) + ); + + cout << 듣도보도못한사람->size() << "\n"; + for (auto name: *듣도보도못한사람) { + cout << name << "\n"; + } + + delete 듣도못한사람; + delete 보도못한사람; + delete 듣도보도못한사람; + +} \ No newline at end of file diff --git a/storage/zeta/kt/completed/25793.kt b/storage/zeta/kt/completed/25793.kt new file mode 100644 index 0000000..de69b38 --- /dev/null +++ b/storage/zeta/kt/completed/25793.kt @@ -0,0 +1,36 @@ +import kotlin.math.min + +fun chocolatePyramidSum(r: Int, c: Int): Long { + val m = min(r, c).toLong() + return m * (4 * m * m - 6 * m * (r.toLong() + c.toLong()) + 12 * r.toLong() * c.toLong() - 1) / 3 +} + +fun chocolatePyramidDark(r: Int, c: Int): Long { + val m = min(r, c).toLong() + return m * (2 * m * m - 3 * m * (r.toLong() + c.toLong()) + 6 * r.toLong() * c.toLong() - 2) / 3 +} + +fun chocolatePyramid(r: Int, c: Int): Pair { + // W(r, c) = (r * c) + (r-1) * (c-1) + D(r-1, c-1) + // D(r, c) = (r - 1) * c + r * (c-1) + W(r-1, c-1) + // therefore, + // W(r, c) = (r * c) + 2*(r-1)*(c-1) ...(until r-k or c-k is equal to 0) + // D(r, c) = (r - 1) * c + r * (c-1) + (r-2) * (c-1) + (r - 1) * (c-2) + //(r*c) + (r-1) * c + r * (c-1) + (r-1) * (c-1) + // S(r, c) = (2r-1)(2c-1) + S(r-1, c-1) + + val s = chocolatePyramidSum(r, c) + val d = chocolatePyramidDark(r, c) + return s - d to d +} + +fun main() = with(System.`in`.bufferedReader()) { + val t = this.readLine().toInt() + repeat(t) { + val (r, c) = this.readLine().split(" ").map { it.toInt() } + + println(chocolatePyramid(r, c).let { + "${it.first} ${it.second}" + }) + } +} \ No newline at end of file