Skip to content

Commit 6b0273c

Browse files
committed
2 parents 1b7eed1 + 0e9f16b commit 6b0273c

4 files changed

Lines changed: 170 additions & 3 deletions

File tree

CCF-CSP/ [CSPro 31] 坐标变换(其二).cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
* @Author: tkzzzzzz6
33
* @Date: 2026-05-26 22:11:02
44
* @LastEditors: tkzzzzzz6
5-
* @LastEditTime: 2026-05-26 22:52:41
5+
* @LastEditTime: 2026-05-27 07:58:22
66
*/
77
#include <cmath>
88
#include <cstdio>
9-
#include <iomanip>
10-
#include <iostream>
119

1210
using namespace std;
1311
const int N = 1e5 + 10;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-05-27 08:59:09
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-05-27 10:04:32
6+
*/
7+
#include <iostream>
8+
#include <vector>
9+
#include <algorithm>
10+
#define endl '\n'
11+
using namespace std;
12+
13+
int main() {
14+
ios::sync_with_stdio(0);
15+
cin.tie(0);
16+
cout.tie(0);
17+
18+
int n, L, r, t;
19+
cin >> n >> L >> r >> t;
20+
21+
vector<vector<int>> A(n, vector<int>(n));
22+
for (int i = 0; i < n; ++i)
23+
for (int j = 0; j < n; ++j)
24+
cin >> A[i][j];
25+
26+
vector<vector<long long>> sum(n, vector<long long>(n));
27+
for (int i = 0; i < n; ++i)
28+
for (int j = 0; j < n; ++j) {
29+
sum[i][j] += A[i][j];
30+
if (i > 0) sum[i][j] += sum[i - 1][j];
31+
if (j > 0) sum[i][j] += sum[i][j - 1];
32+
if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1];
33+
}
34+
35+
auto query = [&](int x1, int y1, int x2, int y2) -> long long {
36+
long long res = sum[x2][y2];
37+
if (x1 > 0) res -= sum[x1 - 1][y2];
38+
if (y1 > 0) res -= sum[x2][y1 - 1];
39+
if (x1 > 0 && y1 > 0) res += sum[x1 - 1][y1 - 1];
40+
return res;
41+
};
42+
43+
int ans = 0;
44+
for (int i = 0; i < n; ++i) {
45+
for (int j = 0; j < n; ++j) {
46+
int x1 = max(0, i - r), y1 = max(0, j - r);
47+
int x2 = min(n - 1, i + r), y2 = min(n - 1, j + r);
48+
long long s = query(x1, y1, x2, y2);
49+
int m = (x2 - x1 + 1) * (y2 - y1 + 1);
50+
if (s <= 1LL * t * m) ans++;
51+
}
52+
}
53+
54+
cout << ans << endl;
55+
56+
return 0;
57+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-05-26 18:59:16
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-05-26 19:08:36
6+
*/
7+
#include <iostream>
8+
#include <vector>
9+
10+
using namespace std;
11+
12+
inline int f(int x, int k) {
13+
return ((x * x + k * k) % 8) ^ k;
14+
}
15+
16+
inline int g(int x, int k) {
17+
int a = (x >> 6) & 7;
18+
int b = (x >> 3) & 7;
19+
int c = x & 7;
20+
21+
int na = b;
22+
int nb = c ^ f(b, k);
23+
int nc = a ^ f(c, k);
24+
25+
return na << 6 | nb << 3 | nc;
26+
}
27+
28+
int main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
int n, m;
33+
cin >> n >> m;
34+
vector<int> k(m);
35+
for (int i = 0; i < m; ++i) cin >> k[i];
36+
37+
vector<int> rev(512);
38+
for (int i = 0; i < 512; ++i) {
39+
int x = i;
40+
for (int j = 0; j < m; ++j) {
41+
x = g(x, k[j]);
42+
}
43+
rev[x] = i;
44+
}
45+
46+
for (int i = 0; i < n; ++i) {
47+
int a;
48+
cin >> a;
49+
cout << rev[a];
50+
if (i + 1 < n) cout << ' ';
51+
}
52+
53+
cout << '\n';
54+
55+
return 0;
56+
}

CCF-CSP/矩阵运算.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-05-27 21:26:47
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-05-27 21:59:17
6+
*/
7+
#include <iostream>
8+
9+
using namespace std;
10+
const int N = 1e4 + 5;
11+
int w[N], q[N][25], v[N][25], k[N][25];
12+
long long back[25][25], t[N][25];
13+
14+
int main() {
15+
ios::sync_with_stdio(0);
16+
cin.tie(0);
17+
cout.tie(0);
18+
19+
int n, d;
20+
cin >> n >> d;
21+
22+
for (int i = 0; i < n; ++i)
23+
for (int j = 0; j < d; ++j)
24+
cin >> q[i][j];
25+
26+
for (int i = 0; i < n; ++i)
27+
for (int j = 0; j < d; ++j)
28+
cin >> k[i][j];
29+
30+
for (int i = 0; i < n; ++i)
31+
for (int j = 0; j < d; ++j)
32+
cin >> v[i][j];
33+
34+
for (int i = 0; i < n; ++i) cin >> w[i];
35+
36+
// 先计算k转置乘v
37+
for (int i = 0; i < d; ++i)
38+
for (int j = 0; j < d; ++j)
39+
for (int r = 0; r < n; ++r)
40+
back[i][j] += 1LL * k[r][i] * v[r][j];
41+
42+
for (int i = 0; i < n; ++i)
43+
for (int j = 0; j < d; ++j)
44+
for (int r = 0; r < d; ++r)
45+
t[i][j] += 1LL * q[i][r] * back[r][j];
46+
47+
for (int i = 0; i < n; ++i) {
48+
for (int j = 0; j < d; ++j) {
49+
if (j) cout << ' ';
50+
cout << w[i] * t[i][j];
51+
}
52+
cout << '\n';
53+
}
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)