AtCoder Beginner Contest 196
导读:
简单的题目,只说明题意,或者直接说明结论
下面的难题,会做详细的解释和证明
立个flag,在座的大佬们做个见证:一个月刷60场ABC,现在2021/6/17,第三天,已打卡4场。
A - Difference Max
嗯,直接取max
void work()
{
int a, b, c, d; cin >> a >> b >> c >> d;
cout << b - c << endl;
}
B - Round Down
题意:输出下取整
void work()
{
string s; cin >> s;
int pos = s.find('.');
s = s.substr(0, pos);
cout << s << endl;
}
C - Doubled
题意:从1到n,对于长度为偶数的x,有多少是前半部分等于后半部分的,那么可以将1e12分成两个1e6,暴力枚举
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin >> n;
int ans = 0;
for (int i = 1; ;i ++ )
if (stoll(to_string(i) + to_string(i)) <= n)
ans ++;
else break;
cout << ans << "\n";
return 0;
}
D - Hanjo
看hw小于等于16,而且只有两种砖头,12和1*1,果断选择爆搜啊DFS走起
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int st[20][20];
int ans = 0;
void dfs(int x, int y, int a, int b)
{
if (a < 0) return;
if (b < 0) return;
if (y == m + 1) return dfs(x + 1, 1, a, b);
if (x == n && y == m)
{
return (void)ans ++;
}
if (st[x][y]) return dfs(x, y + 1, a, b);
if (y < m && !st[x][y + 1] && a > 0)
{
st[x][y] = st[x][y + 1] = true;
dfs(x, y + 1, a - 1, b);
st[x][y] = st[x][y + 1] = false;
}
if (x < n && !st[x + 1][y] && a > 0)
{
st[x][y] = st[x + 1][y] = true;
dfs(x, y + 1, a - 1, b);
st[x][y] = st[x + 1][y] = false;
}
if (b > 0) dfs(x, y + 1, a, b - 1);
}
int main()
{
cin >> n >> m >> a >> b;
dfs(1, 1, a, b);
cout << ans << endl;
return 0;
}