Skip to content

Commit ad8b075

Browse files
committed
add abc174
1 parent 198f2d6 commit ad8b075

File tree

6 files changed

+527
-0
lines changed

6 files changed

+527
-0
lines changed

AtCoder/ABC174/A.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <bits/stdc++.h>
2+
3+
#define int long long
4+
#define double long double
5+
#define ff first
6+
#define ss second
7+
#define endl '\n'
8+
#define ii pair<int, int>
9+
#define mp make_pair
10+
#define mt make_tuple
11+
#define DESYNC \
12+
ios_base::sync_with_stdio(false); \
13+
cin.tie(0); \
14+
cout.tie(0)
15+
#define pb push_back
16+
#define vi vector<int>
17+
#define vii vector<ii>
18+
#define all(x) x.begin(), x.end()
19+
#define EPS 1e-9
20+
#define INF 1e18
21+
#define ROOT 1
22+
#define M 1000000007
23+
#define curtime chrono::steady_clock::now().time_since_epoch().count
24+
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
25+
const double PI = acos(-1);
26+
27+
using namespace std;
28+
29+
inline int mod(int n, int m = M) {
30+
int ret = n % m;
31+
if (ret < 0) ret += m;
32+
return ret;
33+
}
34+
35+
int exp(int n, int k) {
36+
if (k == 0) return 1;
37+
if (k == 1) return n;
38+
int ax = exp(n, k / 2);
39+
ax = mod(ax * ax);
40+
if (k % 2) ax = mod(ax * n);
41+
return ax;
42+
}
43+
44+
int gcd(int a, int b) {
45+
if (a == 0)
46+
return b;
47+
else
48+
return gcd(b % a, a);
49+
}
50+
//#define MULTIPLE_TEST_CASE
51+
void solution() {
52+
int x;
53+
cin >> x;
54+
if (x >= 30)
55+
cout << "Yes" << endl;
56+
else
57+
cout << "No" << endl;
58+
}
59+
60+
int32_t main() {
61+
DESYNC;
62+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
63+
int t = 1;
64+
#ifdef MULTIPLE_TEST_CASE
65+
cin >> t;
66+
#endif
67+
while (t--) solution();
68+
}
69+

AtCoder/ABC174/B.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include <bits/stdc++.h>
2+
3+
#define int long long
4+
#define double long double
5+
#define ff first
6+
#define ss second
7+
#define endl '\n'
8+
#define ii pair<int, int>
9+
#define mp make_pair
10+
#define mt make_tuple
11+
#define DESYNC \
12+
ios_base::sync_with_stdio(false); \
13+
cin.tie(0); \
14+
cout.tie(0)
15+
#define pb push_back
16+
#define vi vector<int>
17+
#define vii vector<ii>
18+
#define all(x) x.begin(), x.end()
19+
#define EPS 1e-9
20+
#define INF 1e18
21+
#define ROOT 1
22+
#define M 1000000007
23+
#define curtime chrono::steady_clock::now().time_since_epoch().count
24+
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
25+
const double PI = acos(-1);
26+
27+
using namespace std;
28+
29+
inline int mod(int n, int m = M) {
30+
int ret = n % m;
31+
if (ret < 0) ret += m;
32+
return ret;
33+
}
34+
35+
int exp(int n, int k) {
36+
if (k == 0) return 1;
37+
if (k == 1) return n;
38+
int ax = exp(n, k / 2);
39+
ax = mod(ax * ax);
40+
if (k % 2) ax = mod(ax * n);
41+
return ax;
42+
}
43+
44+
int gcd(int a, int b) {
45+
if (a == 0)
46+
return b;
47+
else
48+
return gcd(b % a, a);
49+
}
50+
//#define MULTIPLE_TEST_CASE
51+
void solution() {
52+
int n, d;
53+
cin >> n >> d;
54+
int ans = 0;
55+
for (int i = 0; i < n; i++) {
56+
int x, y;
57+
cin >> x >> y;
58+
if (x * x + y * y <= d * d) ans++;
59+
}
60+
cout << ans << endl;
61+
}
62+
63+
int32_t main() {
64+
DESYNC;
65+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
66+
int t = 1;
67+
#ifdef MULTIPLE_TEST_CASE
68+
cin >> t;
69+
#endif
70+
while (t--) solution();
71+
}
72+

AtCoder/ABC174/C.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <bits/stdc++.h>
2+
3+
#define int long long
4+
#define double long double
5+
#define ff first
6+
#define ss second
7+
#define endl '\n'
8+
#define ii pair<int, int>
9+
#define mp make_pair
10+
#define mt make_tuple
11+
#define DESYNC \
12+
ios_base::sync_with_stdio(false); \
13+
cin.tie(0); \
14+
cout.tie(0)
15+
#define pb push_back
16+
#define vi vector<int>
17+
#define vii vector<ii>
18+
#define all(x) x.begin(), x.end()
19+
#define EPS 1e-9
20+
#define INF 1e18
21+
#define ROOT 1
22+
#define M 1000000007
23+
#define curtime chrono::steady_clock::now().time_since_epoch().count
24+
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
25+
const double PI = acos(-1);
26+
27+
using namespace std;
28+
29+
inline int mod(int n, int m = M) {
30+
int ret = n % m;
31+
if (ret < 0) ret += m;
32+
return ret;
33+
}
34+
35+
int exp(int n, int k) {
36+
if (k == 0) return 1;
37+
if (k == 1) return n;
38+
int ax = exp(n, k / 2);
39+
ax = mod(ax * ax);
40+
if (k % 2) ax = mod(ax * n);
41+
return ax;
42+
}
43+
44+
int gcd(int a, int b) {
45+
if (a == 0)
46+
return b;
47+
else
48+
return gcd(b % a, a);
49+
}
50+
//#define MULTIPLE_TEST_CASE
51+
void solution() {
52+
int k;
53+
cin >> k;
54+
int ans = -1;
55+
int acc = 0;
56+
for (int i = 1; i <= k; i++) {
57+
acc = (10 * acc + 7);
58+
acc %= k;
59+
if (acc == 0) {
60+
cout << i << endl;
61+
return;
62+
}
63+
}
64+
cout << -1 << endl;
65+
}
66+
67+
int32_t main() {
68+
DESYNC;
69+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
70+
int t = 1;
71+
#ifdef MULTIPLE_TEST_CASE
72+
cin >> t;
73+
#endif
74+
while (t--) solution();
75+
}
76+

AtCoder/ABC174/D.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <bits/stdc++.h>
2+
3+
#define int long long
4+
#define double long double
5+
#define ff first
6+
#define ss second
7+
#define endl '\n'
8+
#define ii pair<int, int>
9+
#define mp make_pair
10+
#define mt make_tuple
11+
#define DESYNC \
12+
ios_base::sync_with_stdio(false); \
13+
cin.tie(0); \
14+
cout.tie(0)
15+
#define pb push_back
16+
#define vi vector<int>
17+
#define vii vector<ii>
18+
#define all(x) x.begin(), x.end()
19+
#define EPS 1e-9
20+
#define INF 1e18
21+
#define ROOT 1
22+
#define M 1000000007
23+
#define curtime chrono::steady_clock::now().time_since_epoch().count
24+
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
25+
const double PI = acos(-1);
26+
27+
using namespace std;
28+
29+
inline int mod(int n, int m = M) {
30+
int ret = n % m;
31+
if (ret < 0) ret += m;
32+
return ret;
33+
}
34+
35+
int exp(int n, int k) {
36+
if (k == 0) return 1;
37+
if (k == 1) return n;
38+
int ax = exp(n, k / 2);
39+
ax = mod(ax * ax);
40+
if (k % 2) ax = mod(ax * n);
41+
return ax;
42+
}
43+
44+
int gcd(int a, int b) {
45+
if (a == 0)
46+
return b;
47+
else
48+
return gcd(b % a, a);
49+
}
50+
//#define MULTIPLE_TEST_CASE
51+
void solution() {
52+
int ans = 0;
53+
int n;
54+
cin >> n;
55+
string s;
56+
cin >> s;
57+
int l = 0, r = n - 1;
58+
while (l < r) {
59+
while (l < r && s[l] != 'W') l++;
60+
while (l < r && s[r] != 'R') r--;
61+
if (l < r && s[l] == 'W' && s[r] == 'R') {
62+
swap(s[l], s[r]);
63+
ans++;
64+
l++, r--;
65+
}
66+
}
67+
int lastr = -1;
68+
for (int i = 0; i < n; i++) {
69+
if (s[i] == 'R') lastr = i;
70+
}
71+
for (int i = 0; i < lastr; i++) {
72+
if (s[i] == 'W') ans++;
73+
}
74+
cout << ans << endl;
75+
}
76+
77+
int32_t main() {
78+
DESYNC;
79+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
80+
int t = 1;
81+
#ifdef MULTIPLE_TEST_CASE
82+
cin >> t;
83+
#endif
84+
while (t--) solution();
85+
}
86+

AtCoder/ABC174/E.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include <bits/stdc++.h>
2+
3+
#define int long long
4+
#define double long double
5+
#define ff first
6+
#define ss second
7+
#define endl '\n'
8+
#define ii pair<int, int>
9+
#define mp make_pair
10+
#define mt make_tuple
11+
#define DESYNC \
12+
ios_base::sync_with_stdio(false); \
13+
cin.tie(0); \
14+
cout.tie(0)
15+
#define pb push_back
16+
#define vi vector<int>
17+
#define vii vector<ii>
18+
#define all(x) x.begin(), x.end()
19+
#define EPS 1e-9
20+
#define INF 1e18
21+
#define ROOT 1
22+
#define M 1000000007
23+
#define curtime chrono::steady_clock::now().time_since_epoch().count
24+
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
25+
const double PI = acos(-1);
26+
27+
using namespace std;
28+
29+
inline int mod(int n, int m = M) {
30+
int ret = n % m;
31+
if (ret < 0) ret += m;
32+
return ret;
33+
}
34+
35+
int exp(int n, int k) {
36+
if (k == 0) return 1;
37+
if (k == 1) return n;
38+
int ax = exp(n, k / 2);
39+
ax = mod(ax * ax);
40+
if (k % 2) ax = mod(ax * n);
41+
return ax;
42+
}
43+
44+
int gcd(int a, int b) {
45+
if (a == 0)
46+
return b;
47+
else
48+
return gcd(b % a, a);
49+
}
50+
51+
int get_cuts(int cur, int mx) { return (cur - 1) / mx; }
52+
53+
//#define MULTIPLE_TEST_CASE
54+
void solution() {
55+
int n, k;
56+
cin >> n >> k;
57+
int v[n];
58+
for (int i = 0; i < n; i++) cin >> v[i];
59+
int l = 1, r = 1123456789;
60+
int ans = -1;
61+
while (l <= r) {
62+
int m = (l + r) >> 1;
63+
// cout << "testing " << m << endl;
64+
// check whether m is possible
65+
int cuts = 0;
66+
for (int i = 0; i < n; i++) {
67+
// cout << get_cuts(v[i], m) << " ";
68+
cuts += get_cuts(v[i], m);
69+
}
70+
// cout << endl;
71+
if (cuts <= k) {
72+
ans = m;
73+
r = m - 1;
74+
} else {
75+
l = m + 1;
76+
}
77+
}
78+
cout << ans << endl;
79+
}
80+
81+
int32_t main() {
82+
DESYNC;
83+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
84+
int t = 1;
85+
#ifdef MULTIPLE_TEST_CASE
86+
cin >> t;
87+
#endif
88+
while (t--) solution();
89+
}
90+

0 commit comments

Comments
 (0)