A-Okabe and Future Gadget Laboratory
描述
题解
暴力搞搞, O(n4) O ( n 4 ) 水过。
代码
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 55;
int n;
int A[MAXN][MAXN];
int vis[MAXN][MAXN];
int main(int argc, const char * argv[])
{
cin >> n;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
scanf("%d", A[i] + j);
}
}
for (int x = 0; x < n; x++)
{
for (int s = 0; s < n; s++)
{
int t1 = A[x][s];
for (int t = 0; t < n; t++)
{
for (int y = 0; y < n; y++)
{
int t2 = A[t][y];
if (t1 + t2 == A[x][y])
{
vis[x][y] = 1;
}
}
}
}
}
int flag = 1;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (!vis[i][j] && A[i][j] != 1)
{
flag = 0;
break;
}
}
if (!flag)
{
break;
}
}
if (flag)
{
cout << "Yes\n";
}
else
{
cout << "No\n";
}
return 0;
} B-Okabe and Banana Trees
描述
题解
扫描一遍,暴力水过,这里建议扫描纵轴,因为横轴真的太长了,纵轴就短很多了,利用等差公式快速求解即可。
代码
#include <iostream>
using namespace std;
typedef long long ll;
ll m, b;
int main(int argc, const char * argv[])
{
cin >> m >> b;
ll ans = 0;
for (int i = 0; i <= b; i++)
{
ll x = (b - i) * m;
ll s = i * (i + 1) >> 1;
ll e = s + x * (i + 1);
ans = max(ans, (s + e) * (x + 1) >> 1);
}
cout << ans << '\n';
return 0;
} C-Okabe and Boxes
模拟,STL。详解>>>
D-Okabe and City
最短路,难在建图。详解>>>
E-Okabe and El Psy Kongroo
矩阵快速幂优化的动态规划问题。详解>>>

京公网安备 11010502036488号