abc 293 C
// DFS
#include <bits/stdc++.h>
using namespace std;
int h, w;
int a[11][11];
int dx[2] = {0, 1}, dy[2] = {1, 0};
set<int> s;
int dfs(int x, int y)
{
int res = 0;
s.insert(a[x][y]);
if (x == h && y == w) return 1;
for (int i = 0; i < 2; i ++)
{
if (x + dx[i] <= h && y + dy[i] <= w && !s.count(a[x + dx[i]][y + dy[i]]))
{
res += dfs(x + dx[i], y + dy[i]);
s.erase(a[x + dx[i]][y + dy[i]]);
}
}
return res;
}
int main()
{
cin >> h >> w;
for (int i = 1; i <= h; i ++)
for (int j = 1; j <= w; j ++)
cin >> a[i][j];
int ans = dfs(1, 1);
s.erase(a[1][1]);
cout << ans << endl;
return 0;
}
abc 292 C
//排列组合的问题,a * b + c * d == n 的所有四元组
int >> n;
ll ans = 0;
vector<ll> f(n + 1);
for (int i = 1; i <= n; i ++)
for (int j = 1; j * i <= n; j ++)
f[i * j] ++ ;
for (int i = 1; i <= n; i ++)
{
ans += f[i] * f[n - i];
}
cout << ans << endl;
abc 288 C
并查集中每次连接两个在同一个集合的点,会成一环,想要不成环,就要去掉这些边
答案就是这些边的个数