mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-05-10 08:10:27 +08:00
Merge pull request #9 from ToothlessHaveBun/writing
Upload ABC400 codes
This commit is contained in:
commit
618c4b1bd4
BIN
AtCoder/.DS_Store
vendored
Normal file
BIN
AtCoder/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
AtCoder/ABC_400/A
Executable file
BIN
AtCoder/ABC_400/A
Executable file
Binary file not shown.
21
AtCoder/ABC_400/A.cpp
Normal file
21
AtCoder/ABC_400/A.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define INF INT_MAX
|
||||
#define LLM LONG_LONG_MAX
|
||||
#define endl "\n"
|
||||
|
||||
using namespace std;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
int a;
|
||||
|
||||
signed main()
|
||||
{
|
||||
cin >> a;
|
||||
if (400 % a == 0) cout << 400 / a;
|
||||
else cout << -1;
|
||||
return 0;
|
||||
}
|
BIN
AtCoder/ABC_400/B
Executable file
BIN
AtCoder/ABC_400/B
Executable file
Binary file not shown.
55
AtCoder/ABC_400/B.cpp
Normal file
55
AtCoder/ABC_400/B.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define INF INT_MAX
|
||||
#define LLM LONG_LONG_MAX
|
||||
#define endl "\n"
|
||||
|
||||
using namespace std;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
signed main() {
|
||||
int N, M;
|
||||
cin >> N >> M;
|
||||
|
||||
if (N == 1) {
|
||||
lo total = M + 1LL;
|
||||
if (total > 1e9) {
|
||||
cout << "inf" << endl;
|
||||
} else {
|
||||
cout << total << endl;
|
||||
}
|
||||
} else {
|
||||
lo sum = 0;
|
||||
lo cur = 1;
|
||||
bool f = false;
|
||||
for (int i = 0; i <= M; ++i) {
|
||||
sum += cur;
|
||||
if (sum > 1e9) {
|
||||
f = true;
|
||||
break;
|
||||
}
|
||||
if (i == M) {
|
||||
break;
|
||||
}
|
||||
if (cur > 1e9 / N) {
|
||||
f = true;
|
||||
break;
|
||||
}
|
||||
lo next = cur * N;
|
||||
if (next > (1e9 - sum)) {
|
||||
f = true;
|
||||
break;
|
||||
}
|
||||
cur = next;
|
||||
}
|
||||
if (f) {
|
||||
cout << "inf" << endl;
|
||||
} else {
|
||||
cout << sum << endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
AtCoder/ABC_400/C
Executable file
BIN
AtCoder/ABC_400/C
Executable file
Binary file not shown.
41
AtCoder/ABC_400/C.cpp
Normal file
41
AtCoder/ABC_400/C.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define INF INT_MAX
|
||||
#define LLM LONG_LONG_MAX
|
||||
#define endl "\n"
|
||||
|
||||
using namespace std;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
|
||||
signed main() {
|
||||
int N;
|
||||
cin >> N;
|
||||
|
||||
int cnt = 0;
|
||||
int mx = 0;
|
||||
int current = 1;
|
||||
|
||||
while (current <= N) {
|
||||
current *= 2;
|
||||
mx++;
|
||||
}
|
||||
mx--;
|
||||
|
||||
for (int e = 1; e <= mx; ++e) {
|
||||
int m = N / (1 << e);
|
||||
if (m < 1) {
|
||||
continue;
|
||||
}
|
||||
int mx2 = sqrt(m);
|
||||
int cnt = (mx2 + 1) / 2;
|
||||
cnt += cnt;
|
||||
}
|
||||
|
||||
cout << cnt << endl;
|
||||
|
||||
return 0;
|
||||
}
|
20
AtCoder/ABC_400/C.py
Normal file
20
AtCoder/ABC_400/C.py
Normal file
@ -0,0 +1,20 @@
|
||||
import math
|
||||
|
||||
N = int(input())
|
||||
|
||||
count = 0
|
||||
e = 1
|
||||
|
||||
while True:
|
||||
t = 1 << e
|
||||
if t > N:
|
||||
break
|
||||
Q = N // t
|
||||
if Q == 0:
|
||||
e += 1
|
||||
continue
|
||||
m = math.isqrt(Q)
|
||||
cnt += (m + 1) // 2
|
||||
e += 1
|
||||
|
||||
print(cnt)
|
67
AtCoder/ABC_400/D.cpp
Normal file
67
AtCoder/ABC_400/D.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define LLM LONG_LONG_MAX
|
||||
#define endl "\n"
|
||||
|
||||
using namespace std;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
const lo INF = 1e9;
|
||||
const lo dx[] = {1, 0, -1, 0};
|
||||
const lo dy[] = {0, 1, 0, -1};
|
||||
|
||||
signed main() {
|
||||
lo H, W;
|
||||
cin >> H >> W;
|
||||
vector<string> g(H);
|
||||
for (lo i = 0; i < H; ++i) {
|
||||
cin >> g[i];
|
||||
}
|
||||
|
||||
lo A, B, C, D;
|
||||
cin >> A >> B >> C >> D;
|
||||
--A, --B, --C, --D;
|
||||
|
||||
vector<vector<lo>> dist(H, vector<lo>(W, INF));
|
||||
deque<pair<lo, lo>> q;
|
||||
dist[A][B] = 0;
|
||||
q.epb(A, B);
|
||||
|
||||
while (!q.empty()) {
|
||||
auto [x, y] = q.front();
|
||||
q.pop_front();
|
||||
if (x == C && y == D) {
|
||||
cout << dist[x][y] << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (lo i = 0; i < 4; ++i) {
|
||||
lo nx = x + dx[i];
|
||||
lo ny = y + dy[i];
|
||||
if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
|
||||
if (g[nx][ny] == '.') {
|
||||
if (dist[nx][ny] > dist[x][y]) {
|
||||
dist[nx][ny] = dist[x][y];
|
||||
q.epf(nx, ny);
|
||||
}
|
||||
} else {
|
||||
for (lo j = 1; j <= 2; ++j) {
|
||||
lo tx = x + j * dx[i];
|
||||
lo ty = y + j * dy[i];
|
||||
if (tx < 0 || tx >= H || ty < 0 || ty >= W) break;
|
||||
if (g[tx][ty] == '.') break;
|
||||
if (dist[tx][ty] > dist[x][y] + 1) {
|
||||
dist[tx][ty] = dist[x][y] + 1;
|
||||
q.epb(tx, ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << -1 << '\n';
|
||||
return 0;
|
||||
}
|
BIN
AtCoder/ABC_400/__pycache__/C.cpython-313.pyc
Normal file
BIN
AtCoder/ABC_400/__pycache__/C.cpython-313.pyc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user