-
最弱智的第三题,只需要按照题意模拟即可,不要少看条件即可满分
#include <bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
double a[8][8];
double data[70];
double vis[8][8];
double tc[8][8];
double res[8][8];
int ans[8][8];
double alpha(int x) {
if (x == 0) return sqrt(0.5);
else return 1;
}
void LS(int i, int j) {
double x = 0;
for (int u = 0; u < 8; ++u) {
for (int v = 0; v < 8; ++v) {
x += alpha(u) * alpha(v) * cos(acos(-1)/8.0*(i + 0.5)*u) *
cos(acos(-1)/8.0*(j+0.5)*v) * res[u][v];
}
}
x = x / 4.0 + 128;
if (x - (int)x >= 0.5) {
x = (int)x + 1;
} else {
x = (int)x;
}
if (x >= 255) x = 255;
if (x < 0) x = 0;
ans[i][j] = x;
}
void print(int T) {
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (T == 0) cout << tc[i][j] << " ";
else if (T == 1) cout << res[i][j] << " ";
else if (T == 2) cout << ans[i][j] << " ";
} cout << endl;
}
}
void solve() {
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j) cin >> a[i][j];
int n, T; cin >> n >> T;
for (int i = 0; i < n; ++i) cin >> data[i];
int cnt = 1, x = 0, y = 0;
res[x][y] = data[0]; vis[0][0] = 1;
while (cnt < n) {
if (!vis[x][y+1] && y < 7 && cnt < n) {
vis[x][y+1] = 1;
res[x][y+1] = data[cnt++];
y ++;
}
while (x < 7 && y > 0 && !vis[x+1][y-1] && cnt < n){
res[x+1][y-1] = data[cnt++];
vis[x+1][y-1] = 1;
x++; y--;
}
if (x < 7 && !vis[x+1][y] && cnt < n) {
res[x+1][y] = data[cnt++];
vis[x+1][y] = 1;
x++;
}
while (x > 0 && y < 7 && !vis[x-1][y+1] && cnt < n) {
res[x-1][y+1] = data[cnt++];
vis[x-1][y+1] = 1;
x--; y++;
}
}
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j) {
tc[i][j] = res[i][j];
res[i][j] *= a[i][j];
}
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j)
LS(i, j);
print(T);
}
int main() {
solve();
return 0;
}