From 234951bf3619b7375dac7b5a9605a2a16059af88 Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:39:21 +0900 Subject: [PATCH 1/6] atcoder/abc052A --- atcoder/abc052/A/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 atcoder/abc052/A/main.cpp diff --git a/atcoder/abc052/A/main.cpp b/atcoder/abc052/A/main.cpp new file mode 100644 index 00000000..3e17eb68 --- /dev/null +++ b/atcoder/abc052/A/main.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; +using ll = long long; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + int A, B, C, D; + cin >> A >> B >> C >> D; + + int S = A * B, R = C * D; + if (S > R) { + cout << S << endl; + } else { + cout << R << endl; + } + + return 0; +} \ No newline at end of file From ebcf5022db869d639f8af717b630a624b729a322 Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:39:27 +0900 Subject: [PATCH 2/6] atcoder/abc052B --- atcoder/abc052/B/main.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 atcoder/abc052/B/main.cpp diff --git a/atcoder/abc052/B/main.cpp b/atcoder/abc052/B/main.cpp new file mode 100644 index 00000000..211a2356 --- /dev/null +++ b/atcoder/abc052/B/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; +using ll = long long; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + int N; + string S; + cin >> N >> S; + + int maxx = 0; + int x = 0; + for (auto ch : S) { + if (ch == 'I') ++x; + if (ch == 'D') --x; + maxx = max(maxx, x); + } + cout << maxx << endl; + + return 0; +} \ No newline at end of file From 6d2be5e33d7a2d15c81bbb196d88aa881df60204 Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:39:39 +0900 Subject: [PATCH 3/6] atcoder/abc052C --- atcoder/abc052/C/main.cpp | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 atcoder/abc052/C/main.cpp diff --git a/atcoder/abc052/C/main.cpp b/atcoder/abc052/C/main.cpp new file mode 100644 index 00000000..bcccc765 --- /dev/null +++ b/atcoder/abc052/C/main.cpp @@ -0,0 +1,57 @@ +#include + +using namespace std; +using ll = long long; + +ll const MOD = 1e9+7; +int const M = 1e3+1; + +set seive() { + vector is_prime(M, true); + is_prime[0] = is_prime[1] = false; + for (int i = 2; i * i <= M; ++i) { + if (!is_prime[i]) continue; + for (int j = i * 2; j < M; j += i) { + is_prime[j] = false; + } + } + + set primes; + for (int i = 2; i < M; ++i) { + if (is_prime[i]) { + primes.insert(i); + } + } + return primes; +} + +ll solve(int N) { + auto primes = seive(); + vector factors(M, 0); + for (int i = N; i >= 2; --i) { + int v = i; + for (auto p : primes) { + while (v % p == 0) { + v /= p; + ++factors[p]; + } + } + } + + ll ans = 1; + for (int i = 0; i < M; ++i) { + ans = (ans * (factors[i]+1)) % MOD; + } + return ans; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + int N; + cin >> N; + cout << solve(N) << endl; + + return 0; +} \ No newline at end of file From 84b04e3fc8ba49a8399e811d9e6b539a5d397820 Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:39:48 +0900 Subject: [PATCH 4/6] atcoder/abc052D --- atcoder/abc052/D/main.cpp | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 atcoder/abc052/D/main.cpp diff --git a/atcoder/abc052/D/main.cpp b/atcoder/abc052/D/main.cpp new file mode 100644 index 00000000..4e2358ba --- /dev/null +++ b/atcoder/abc052/D/main.cpp @@ -0,0 +1,45 @@ +#include + +using namespace std; +using ll = long long; + +int N, A, B; +vector X; + +ll solve() { + vector> es; + for (int i = 1; i < N; ++i) { + int w = X[i] - X[i-1]; + es.push_back({ w, i - 1, i }); + } + + vector has_next(N, false); + ll ans = 0; + sort(es.begin(), es.end()); + for (auto const& e : es) { + ll w = e[0]; + int u = e[1]; + if (w * A >= B) continue; + ans += w * A; + has_next[u] = true; + } + for (int i = 0; i < N - 1; ++i) { + if (has_next[i]) continue; + ans += B; + } + return ans; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> N >> A >> B; + X.assign(N, 0); + for (int i = 0; i < N; ++i) { + cin >> X[i]; + } + cout << solve() << endl; + + return 0; +} \ No newline at end of file From f6e3dc2209061942cad15249a75b5439b4204e1a Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:43:44 +0900 Subject: [PATCH 5/6] atcoder/abc052A (feedback from editorial) --- atcoder/abc052/A/main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/atcoder/abc052/A/main.cpp b/atcoder/abc052/A/main.cpp index 3e17eb68..c9384b61 100644 --- a/atcoder/abc052/A/main.cpp +++ b/atcoder/abc052/A/main.cpp @@ -11,11 +11,7 @@ int main() { cin >> A >> B >> C >> D; int S = A * B, R = C * D; - if (S > R) { - cout << S << endl; - } else { - cout << R << endl; - } + cout << max(S, R) << endl; return 0; } \ No newline at end of file From 04905ae13b36e5a781e88c932a840df7deb88924 Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Wed, 13 Jan 2021 22:46:55 +0900 Subject: [PATCH 6/6] atcoder/abc052D (feedback from editorial) --- atcoder/abc052/D/main.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/atcoder/abc052/D/main.cpp b/atcoder/abc052/D/main.cpp index 4e2358ba..de4172ea 100644 --- a/atcoder/abc052/D/main.cpp +++ b/atcoder/abc052/D/main.cpp @@ -7,25 +7,10 @@ int N, A, B; vector X; ll solve() { - vector> es; - for (int i = 1; i < N; ++i) { - int w = X[i] - X[i-1]; - es.push_back({ w, i - 1, i }); - } - - vector has_next(N, false); ll ans = 0; - sort(es.begin(), es.end()); - for (auto const& e : es) { - ll w = e[0]; - int u = e[1]; - if (w * A >= B) continue; - ans += w * A; - has_next[u] = true; - } - for (int i = 0; i < N - 1; ++i) { - if (has_next[i]) continue; - ans += B; + for (int i = 1; i < N; ++i) { + ll w = X[i] - X[i-1]; + ans += min(w * A, ll(B)); } return ans; }