baidu
冰雪大冒险
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
std::cin >> n >> m;
int sx, sy;
std::cin >> sx >> sy;
int k;
std::cin >> k;
std::vector<std::vector<int>> a(n + 1, std::vector<int>(m + 1));
for (int i = 0; i < k; i++) {
int x, y;
std::cin >> x >> y;
a[x][y] = 1;
}
std::string s;
std::cin >> s;
auto trans = [&](char ch) -> std::array<int, 2> {
if (ch == 'D') return std::array<int, 2>{1, 0};
else if (ch == 'L') return std::array<int, 2>{0, -1};
else if (ch == 'R') return std::array<int, 2>{0, 1};
else return std::array<int, 2>{-1, 0};
};
for (int i = 0; i < static_cast<int>(s.size()); i++) {
std::array<int, 2> now = trans(s[i]);
int xx = sx + now[0], yy = sy + now[1];
while(xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == 0) {
sx = xx, sy = yy;
// std::cerr << KV(sx) << " " << KV(sy) << "\n";
xx += now[0], yy += now[1];
}
}
std::cout << sx << " " << sy << "\n";
}
房间打扫
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int Max = 0;
std::map<std::string, int> cnt;
int n;
std::cin >> n;
for (int i = 0; i < n; i++) {
std::string s;
std::cin >> s;
cnt[s]++;
Max = std::max(cnt[s], Max);
}
std::cout << Max << "\n";
}
数字统计
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n;
std::cin >> n;
int ans = 0;
auto trans = [&](int x) -> bool {
std::string now = std::to_string(x);
std::reverse(now.begin(), now.end());
int y = stoi(now);
return x % y == 0;
};
for (int i = 1; i <= n; i++) {
ans += trans(i);
}
std::cout << ans << "\n";
}
函数的幂
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int a, b, C, D;
std::cin >> a >> b >> C >> D;
int ans = 0;
std::function<int(int, int)> f = [&](int x, int y) -> int {
if (x == 1) return (1ll * C * y % 10 + D % 10) % 10;
else {
return f(x - 1, f(x - 1, y));
}
};
std::cout << f(a, b) << "\n";
}
项链
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n;
std::cin >> n;
std::vector<int> a(n);
for (auto& x : a) std::cin >> x;
std::sort(a.begin(), a.end());
long long ans = 0;
for (int i = n - 1; i >= (n + 1) / 2; i--) ans += a[i];
for (int i = 0; i < n / 2; i++) ans -= a[i];
ans <<= 1;
std::cout << ans << "\n";
}
污渍
#include <bits/stdc++.h>
#define KV(x) #x << " " << x
#define int long long
signed main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
std::vector<std::array<int, 3>> p(2);
long long ans = 0;
for (int i = 0; i < 2; i++) {
std::cin >> p[i][0] >> p[i][1] >> p[i][2];
ans += 1ll * p[i][2] * p[i][2];
}
std::pair<int, int> A = std::make_pair(std::min(std::max(p[0][0], p[1][0]), std::min(p[0][0] + p[0][2], p[1][0] + p[1][2])),
std::max(std::min(p[0][1], p[1][1]), std::max(p[0][1] - p[0][2], p[1][1] - p[1][2])));
std::pair<int, int> B = std::make_pair(std::min(p[1][0] + p[1][2], p[0][0] + p[0][2]),
std::max(p[1][1] - p[1][2], p[0][1] - p[0][2]));
// std::cout << A.first << " " << A.second << "\n";
// std::cout << B.first << " " << B.second << "\n";
if (B.first >= A.first && B.second <= A.second)
ans -= std::max(0ll, 1ll * (B.first - A.first) * (A.second - B.second));
std::cout << ans << "\n";
}
剧场
#include <bits/stdc++.h>
signed main() {
int n;
std::cin >> n;
std::vector<std::vector<char>> g(n + 10, std::vector<char>(n + 10, '0'));
int N = n * n;
for (int tc = 0; tc < N; tc++) {
for (int i = n; i; i--) {
for (int j = n; j; j--) {
if (j == 1) {
if (g[i][j] == '0' && g[i - 1][n] == '1') {
g[i][j] = '1';
g[i - 1][n] = '0';
}
} else {
if (g[i][j] == '0' && g[i][j - 1] == '1') {
g[i][j] = '1';
g[i][j - 1] = '0';
}
}
}
}
char ch;
std::cin >> ch;
if (ch & 1)
g[1][1] = '1';
int ans = 0;
for (int i = 1; i <= n; i++) {
int ok = 0;
for (int j = 1; j <= n; j++) {
if (g[i][j] == '1')
ok |= 1;
}
ans += ok;
}
std::cout << ans << " \n"[tc == N - 1];
}
}
__EOF__

本文作者:HoneyGrey
本文链接:https://www.cnblogs.com/Haven-/p/17341497.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/Haven-/p/17341497.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!