File tree 4 files changed +128
-0
lines changed
4 files changed +128
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments