AtCoder Beginner Contest 176
比赛链接:https://atcoder.jp/contests/abc176
A - Takoyaki
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, t;
cin >> n >> x >> t;
cout << (n + x - 1) / x * t << "\n";
}
B - Multiple of 9
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int mod = 0;
for (char c : s) {
mod += c - '0';
mod %= 9;
}
cout << (mod == 0 ? "Yes" : "No") << "\n";
}
C - Step
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long ans = 0;
int mx = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
mx = max(mx, x);
ans += mx - x;
}
cout << ans << "\n";
}
D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; int h, w;
int c_h, d_h, c_w, d_w;
int ans = -1;
string MP[N];
bool vis[N][N]; struct P{
int x, y;
int cnt;
}; bool inside(int x, int y) {
return x >= 0 and x < h and y >= 0 and y < w;
} void bfs() {
deque<P> dque;
dque.push_front({c_h, c_w, 0});
while (!dque.empty()) {
auto [x, y, cnt] = dque.front();
dque.pop_front();
if (x == d_h and y == d_w) {
ans = cnt;
break;
}
if (vis[x][y]) continue;
vis[x][y] = true;
for (int i = 0; i < 4; i++) {
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if (inside(nx, ny) and MP[nx][ny] == '.')
dque.push_front({nx, ny, cnt});
}
for (int nx = x - 2; nx <= x + 2; nx++) {
for (int ny = y - 2; ny <= y + 2; ny++) {
if (inside(nx, ny) and MP[nx][ny] == '.')
dque.push_back({nx, ny, cnt + 1});
}
}
}
} int main() {
cin >> h >> w;
cin >> c_h >> c_w >> d_h >> d_w;
--c_h, --c_w, --d_h, --d_w;
for (int i = 0; i < h; i++)
cin >> MP[i];
bfs();
cout << ans << "\n";
}
E - Bomber
#include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
int m;
cin >> m;
int mxr = 0, mxc = 0;
vector<int> row(h), col(w);
vector<pair<int, int>> v;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
--x, --y;
mxr = max(mxr, ++row[x]);
mxc = max(mxc, ++col[y]);
v.emplace_back(x, y);
}
int inter = 0;
for (auto [x, y] : v) {
if (row[x] == mxr and col[y] == mxc)
++inter;
}
int cnt_mxr = count(row.begin(), row.end(), mxr);
int cnt_mxc = count(col.begin(), col.end(), mxc);
cout << (mxr + mxc - (inter == 1ll * cnt_mxr * cnt_mxc)) << "\n";
}
参考博客
https://www.cnblogs.com/lr599909928/p/13559189.html
https://www.cnblogs.com/lr599909928/p/13559245.html
AtCoder Beginner Contest 176的更多相关文章
- AtCoder Beginner Contest 176 D - Wizard in Maze (BFS,双端队列)
题意:给你一张图,"."表示能走,"#表示不能走,步行可以向四周四个方向移动一个单位,使用魔法可以移动到周围\(5\)X\(5\)的空地,问能否从起点都早终点,并求最少使 ...
- AtCoder Beginner Contest 176 E - Bomber (思维)
题意:有一张\(H\)x\(W\)的图,给你\(M\)个目标的位置,你可以在图中放置一枚炸弹,炸弹可以摧毁所在的那一行和一列,问最多可以摧毁多少目标. 题解:首先我们记录某一行和某一列目标最多的数目, ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】
AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...
随机推荐
- Java NIO 文件通道 FileChannel 用法
FileChannel 提供了一种通过通道来访问文件的方式,它可以通过带参数 position(int) 方法定位到文件的任意位置开始进行操作,还能够将文件映射到直接内存,提高大文件的访问效率.本文将 ...
- MySQL select 语句指定字段查询
指定字段查询 SELECT 语法 SELECT [ALL | DISTINCT] {* | table.* | [table.field1[as alias1][,table.field2[as al ...
- LeetCode530. 二叉搜索树的最小绝对差
题目 又是常见的BST,要利用BST的性质,即中序遍历是有序递增序列. 法一.中序遍历 1 class Solution { 2 public: 3 vector<int>res; 4 v ...
- 攻防世界—pwn—int_overflow
题目分析 checksec检查文件保护机制 ida分析程序 经典整数溢出漏洞示例 整数溢出原理整数分为有符号和无符号两种类型,有符号数以最高位作为其符号位,即正整数最高位为1,负数为0, 无符号数取值 ...
- 三节锂电池充电管理芯片,IC电路图如何设计
关于三节锂电池供电的产品,在三节锂电池上,需要三个电路系统: 1,三节锂电池保护电路, 2,三节锂电池充电电路, 3,三节锂电池输出电路. 1.三节锂电池保护电路,芯片电路图 控制三节锂电池池的充电电 ...
- 如何在 crontab 中让 source ~/.bashrc 生效
cron 是许多类 Unix 操作系统中都自带的用来调度定时任务的工具,定时任务的配置是写在 crontab 文件中的,但是 crontab 文件不允许直接编辑,一般都是通过命令 crontab -e ...
- Devexpress DockManager多页面浮动窗口会关闭所有页面的问题
注册 DockManager 的 ClosingPanel 事件 private void DockManager1_ClosingPanel(object sender, DockPanelCanc ...
- spark开窗函数
源文件内容示例: http://bigdata.beiwang.cn/laoli http://bigdata.beiwang.cn/laoli http://bigdata.beiwang.cn/h ...
- 避免重复提交?分布式服务的幂等性设计! 架构文摘 今天 点击蓝色“架构文摘”关注我哟 加个“星标”,每天上午 09:25,干货推送! 来源:https://www.cnblogs.com/QG-whz/p/10372458.html 作者:melonstreet
避免重复提交?分布式服务的幂等性设计! 架构文摘 今天 点击蓝色"架构文摘"关注我哟 加个"星标",每天上午 09:25,干货推送! 来源:h ...
- __init__ raises an exception, then __del__ will still be called
issue 808164: socket.close() doesn't play well with __del__ - Python tracker https://bugs.python.org ...