Skip to content

Commit 35813ba

Browse files
authored
Merge pull request #317 from xirc/atcoder/abc052
AtCoder/ABC052
2 parents dd2a508 + 04905ae commit 35813ba

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

atcoder/abc052/A/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
int A, B, C, D;
11+
cin >> A >> B >> C >> D;
12+
13+
int S = A * B, R = C * D;
14+
cout << max(S, R) << endl;
15+
16+
return 0;
17+
}

atcoder/abc052/B/main.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
int N;
11+
string S;
12+
cin >> N >> S;
13+
14+
int maxx = 0;
15+
int x = 0;
16+
for (auto ch : S) {
17+
if (ch == 'I') ++x;
18+
if (ch == 'D') --x;
19+
maxx = max(maxx, x);
20+
}
21+
cout << maxx << endl;
22+
23+
return 0;
24+
}

atcoder/abc052/C/main.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
ll const MOD = 1e9+7;
7+
int const M = 1e3+1;
8+
9+
set<int> seive() {
10+
vector<bool> is_prime(M, true);
11+
is_prime[0] = is_prime[1] = false;
12+
for (int i = 2; i * i <= M; ++i) {
13+
if (!is_prime[i]) continue;
14+
for (int j = i * 2; j < M; j += i) {
15+
is_prime[j] = false;
16+
}
17+
}
18+
19+
set<int> primes;
20+
for (int i = 2; i < M; ++i) {
21+
if (is_prime[i]) {
22+
primes.insert(i);
23+
}
24+
}
25+
return primes;
26+
}
27+
28+
ll solve(int N) {
29+
auto primes = seive();
30+
vector<int> factors(M, 0);
31+
for (int i = N; i >= 2; --i) {
32+
int v = i;
33+
for (auto p : primes) {
34+
while (v % p == 0) {
35+
v /= p;
36+
++factors[p];
37+
}
38+
}
39+
}
40+
41+
ll ans = 1;
42+
for (int i = 0; i < M; ++i) {
43+
ans = (ans * (factors[i]+1)) % MOD;
44+
}
45+
return ans;
46+
}
47+
48+
int main() {
49+
ios_base::sync_with_stdio(false);
50+
cin.tie(0); cout.tie(0);
51+
52+
int N;
53+
cin >> N;
54+
cout << solve(N) << endl;
55+
56+
return 0;
57+
}

atcoder/abc052/D/main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N, A, B;
7+
vector<int> X;
8+
9+
ll solve() {
10+
ll ans = 0;
11+
for (int i = 1; i < N; ++i) {
12+
ll w = X[i] - X[i-1];
13+
ans += min(w * A, ll(B));
14+
}
15+
return ans;
16+
}
17+
18+
int main() {
19+
ios_base::sync_with_stdio(false);
20+
cin.tie(0); cout.tie(0);
21+
22+
cin >> N >> A >> B;
23+
X.assign(N, 0);
24+
for (int i = 0; i < N; ++i) {
25+
cin >> X[i];
26+
}
27+
cout << solve() << endl;
28+
29+
return 0;
30+
}

0 commit comments

Comments
 (0)