题1题述
输入输出
数据范围、样例
代码
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;
int n,t=-100;
int a[N];
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i],t=max(t,a[i]);
int ans=t^a[n];
cout<<ans;
}
题2题述
输入输出
数据范围、样例
代码
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
string s1, s2;
int a[N][N];
int dx[] = {2, 2, 1, 1, -1, -1, -2, -2};
int dy[] = {1, -1, 2, -2, 2, -2, 1, -1};
void dfs(int x, int y) {
a[x][y] = 1;
for (int i = 0; i < 8; i++) {
int xx = dx[i] + x;
int yy = dy[i] + y;
if (xx < 1 || xx > 8 || yy < 1 || yy > 8 || a[xx][yy]) continue;
a[xx][yy] = 1;
}
}
int main() {
cin >> s1 >> s2;
int x = s1[0] - 'a' + 1, y = s1[1] - '0';
int xx = s2[0] - 'a' + 1, yy = s2[1] - '0';
dfs(xx, yy);
int cnt = 0;
for (int i = 1; i <= 8; i++)
for (int j = 1; j <= 8; j++) {
if (i == x || j == y || a[i][j]) continue;
bool flag = true;
for (int k = 0; k < 8; k++) {
int tx = i + dx[k];
int ty = j + dy[k];
if (tx == x && ty == y) {
flag = false;
break;
}
if (tx == xx && ty == yy) {
flag = false;
break;
}
}
if (flag) cnt++;
}
cout << cnt << endl;
return 0;
}