Skip to content

Commit c085959

Browse files
author
ksh-code
committed
y
1 parent 5ffeeff commit c085959

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

atcoder/a

2.62 KB
Binary file not shown.

atcoder/abc248_a.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ using namespace std;
33
typedef long long ll;
44

55
void solve(){
6+
string str;
7+
cin >> str;
8+
set<char> s;
9+
for (auto c : str) {
10+
s.insert(c);
11+
}
12+
for (char i = '0'; i <= '9'; i++) {
13+
if (!s.count(i)) {
14+
cout << i;
15+
}
16+
}
617
}
718

819
int main()

atcoder/abc248_b.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ using namespace std;
33
typedef long long ll;
44

55
void solve(){
6+
ll A,B,K; cin >> A >> B >>K;
7+
int i = 0;
8+
while (A < B) {
9+
A*=K;
10+
i++;
11+
}
12+
cout << i;
613
}
714

815
int main()

atcoder/abc248_c.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,31 @@
22
using namespace std;
33
typedef long long ll;
44

5+
const ll MOD = 998244353;
6+
int M;
7+
8+
ll dp[51][2501];
9+
10+
ll dfs(int N, int remains) {
11+
if (dp[N][remains]) return dp[N][remains];
12+
13+
if (N == 1) {
14+
return dp[N][remains] = min(remains, M);
15+
}
16+
17+
ll result = 0;
18+
for (int i = 1; i <= M; i++) {
19+
if (i >= remains) break;
20+
result += dfs(N-1, remains-i);
21+
result %= MOD;
22+
}
23+
24+
return dp[N][remains] = result % MOD + MOD;
25+
}
26+
527
void solve(){
28+
int N, K; cin >> N >> M >>K;
29+
cout << dfs(N, K) % MOD;
630
}
731

832
int main()

atcoder/abc248_d.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,47 @@
22
using namespace std;
33
typedef long long ll;
44

5+
const int MAX = 2e5;
6+
7+
unordered_map<int, int> tree[MAX*4];
8+
9+
void update(int s, int e, int node, int index, int f) {
10+
if (s > index || e < index) return;
11+
12+
tree[node][f]++;
13+
if (s == e) return;
14+
15+
int m = (s+e)/2;
16+
update(s, m, node*2, index, f);
17+
update(m+1, e, node*2+1, index, f);
18+
}
19+
20+
int query(int s, int e, int node, int l, int r, int c) {
21+
if (s > r || e < l) return 0;
22+
if (l <= s && r >= e) {
23+
if (tree[node].count(c)) return tree[node][c];
24+
return 0;
25+
}
26+
27+
int m = (s+e)/2;
28+
return query(s, m, node*2, l, r, c) + query(m+1, e, node*2+1, l, r, c);
29+
}
30+
531
void solve(){
32+
int N; cin >> N;
33+
for (int i = 1; i <= N; i++) {
34+
int a; cin >> a;
35+
update(1, N, 1, i, a);
36+
}
37+
38+
int M; cin >> M;
39+
while (M--) {
40+
int l, r, c;
41+
cin >> l >> r >> c;
42+
cout << query(1, N, 1, l, r, c);
43+
cout << '\n';
44+
}
45+
646
}
747

848
int main()

atcoder/abc248_e.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,53 @@
22
using namespace std;
33
typedef long long ll;
44

5+
pair<ll,ll> points[300];
6+
bool used[300][300];
7+
8+
bool check(int a, int b, int c) {
9+
auto [x1, y1] = points[a];
10+
auto [x2, y2] = points[b];
11+
auto [x3, y3] = points[c];
12+
13+
return (x2-x1)*(y3-y1) == (x3-x1)*(y2-y1);
14+
}
15+
516
void solve(){
17+
int N, K; cin >> N >> K;
18+
if (K == 1) {
19+
cout << "Infinity";
20+
return;
21+
}
22+
23+
for (int i = 0; i < N; i++) {
24+
cin >> points[i].first >> points[i].second;
25+
}
26+
27+
28+
int result = 0;
29+
for (int i = 0; i < N; i++) {
30+
for (int j = i + 1; j < N; j++) {
31+
if (used[i][j]) continue;
32+
33+
vector<int> p;
34+
p.push_back(i);
35+
p.push_back(j);
36+
for (int k = j + 1; k < N; k++) {
37+
if (check(i,j,k)) {
38+
p.push_back(k);
39+
}
40+
}
41+
42+
for (int pi = 0; pi < p.size(); pi++) {
43+
for (int pj = pi + 1; pj < p.size(); pj++) {
44+
used[p[pi]][p[pj]]=true;
45+
}
46+
}
47+
48+
if (p.size() >= K) result++;
49+
}
50+
}
51+
cout << result;
652
}
753

854
int main()

0 commit comments

Comments
 (0)