#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define LL long long
#define INF 0x3f3f3f3f
#define EPS 1e-12
#define PI 3.141592653579798
#define maxn 1e5+10;
#define MOD 1e9+7;
//#define scanf scanf_s
using namespace std;
inline int rd() {
int f = 0; int x = 0; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
if (f) x = -x;
return x;
}
double liang[10][10], m[10][10];
double ef[9] = { 0,sqrt(1.0 / 2.0),1,1,1,1,1,1,1 };
struct zb {
int x, y;
};
zb judge(zb a) {
zb b;
if (a.x + a.y < 9) {
if ((a.x + a.y) % 2 == 0) {//上
b.x = a.x - 1;
if (b.x == 0) b.x++;
b.y = a.y + 1;
}
else {//下
b.x = a.x + 1;
b.y = a.y - 1;
if (b.y == 0) b.y++;
}
}
else {
if ((a.x + a.y) % 2 == 0) {//上
if (a.y == 8) b.x = a.x + 1;
else {
b.x = a.x - 1;
b.y = a.y + 1;
}
}
else {//下
if (a.x == 8) b.y = a.y + 1;
else {
b.x = a.x - 1;
b.y = a.y + 1;
}
}
}
return b;
}
int main()
{
for (int i = 1; i <= 8; i++)
for (int j = 1; j <= 8; j++)
liang[i][j] = rd();
int n, t;
cin >> n >> t;
zb pos;
pos.x = 1, pos.y = 1;
for (int i = 1; i <= n; i++) {
m[pos.x][pos.y] = rd();
pos = judge(pos);
}
if (t == 0) {
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
cout << m[i][j] << ' ';
}
cout << endl;
}
}
else if (t == 1) {
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
cout << m[i][j]*liang[i][j] << ' ';
}
cout << endl;
}
}
else {
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
double ans = 0, res = 0;
for (int u = 1; u <= 8; u++) {
for (int v = 1; v <= 8; v++) {
ans += ef[u] * ef[v] * m[u][v] * liang[u][v] * cos(PI / 8.0 * ((double)(i - 1.0) + 0.5) * (u - 1.0)) * cos(PI / 8.0 * ((double)(j - 1.0) + 0.5) * (v - 1.0));
}
}
ans = ans / 4.0;
res = round(ans + 128.0);
if (res > 255) res = 255;
if (res < 0) res = 0;
cout << res << ' ';
}
cout << endl;
}
}
return 0;
}
202212-3 JPEG 解码(搞错了)
最新推荐文章于 2024-08-13 15:05:22 发布