2 Commits
07_01 ... 07_02

Author SHA1 Message Date
unlockable
21ee0141ac AC. 2023-12-12 00:31:40 +08:00
unlockable
23114b575a 为什么少了一个tle?? 2023-12-11 23:54:45 +08:00

View File

@@ -1,10 +1,11 @@
#include <math.h>
#include <stdio.h> #include <stdio.h>
int p = 0; int p = 0;
int m = 0, n = 0; int m = 0, n = 0;
double A[5][10000] = {0}, Z[10000] = {0}; double A[5][10000], Z[10000];
double get_content(int row, int column) { double get_content(int row, int column) {
if (row - column > 2 || row - column < -2) { if (abs(row - column) > p / 2) {
return 0; return 0;
} }
if (row < 0 || row >= n) { if (row < 0 || row >= n) {
@@ -13,11 +14,11 @@ double get_content(int row, int column) {
if (column < 0 || column >= n) { if (column < 0 || column >= n) {
return 0; return 0;
} }
return A[(row - column + 2)][column]; return A[(row - column + p / 2)][column];
} }
int set_content(int row, int column, double val) { int set_content(int row, int column, double val) {
if (row - column > 2 || row - column < -2) { if (abs(row - column) > p / 2) {
return 0; return 0;
} }
if (row < 0 || row >= n) { if (row < 0 || row >= n) {
@@ -26,24 +27,24 @@ int set_content(int row, int column, double val) {
if (column < 0 || column >= n) { if (column < 0 || column >= n) {
return 0; return 0;
} }
A[(row - column + 2)][column] = val; A[(row - column + p / 2)][column] = val;
return 0; return 0;
} }
int output() { // int output() {
for (int i = 0; i < p; i++) { // for (int i = 0; i < p; i++) {
for (int j = 0; j < n; j++) { // for (int j = 0; j < n; j++) {
printf("%lf ", get_content(i, j)); // printf("%lf ", get_content(i, j));
} // }
printf("\n"); // printf("\n");
} // }
printf("\n"); // printf("\n");
return 0; // return 0;
} // }
int outputZ() { int outputZ() {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
printf("%lf ", Z[i]); printf("%.4lf ", Z[i]);
} }
printf("\n"); printf("\n");
return 0; return 0;
@@ -52,23 +53,13 @@ int outputZ() {
int main() { int main() {
scanf("%d", &p); scanf("%d", &p);
scanf("%d %d", &n, &m); scanf("%d %d", &n, &m);
// for (int i = 0; i < p / 2; i++) { for (int i = 0; i < p / 2; i++) {
// for (int j = p / 2 - i; j < n; j++) { for (int j = p / 2 - i; j < n; j++) {
// scanf("%lf", &A[i][j]);
// }
// }
// for (int i = p / 2; i < p; i++) {
// for (int j = 0; j < n - (i - p / 2); j++) {
// scanf("%lf", &A[i][j]);
// }
// }
for (int i = 2 - p / 2; i <= 2; i++) {
for (int j = 2 - i; j < n; j++) {
scanf("%lf", &A[i][j]); scanf("%lf", &A[i][j]);
} }
} }
for (int i = 3; i <= 2 + p / 2; i++) { for (int i = p / 2; i < p; i++) {
for (int j = 0; j < n - (i - 2); j++) { for (int j = 0; j < n - (i - p / 2); j++) {
scanf("%lf", &A[i][j]); scanf("%lf", &A[i][j]);
} }
} }
@@ -84,7 +75,7 @@ int main() {
if (base != 0) { if (base != 0) {
double coefficient = base / diag_elem; double coefficient = base / diag_elem;
set_content(row, col, -coefficient); set_content(row, col, -coefficient);
for (int l = col + 1; l < n; l++) { for (int l = col + 1; l < col + 3; l++) {
set_content(row, l, get_content(row, l) - coefficient * get_content(col, l)); set_content(row, l, get_content(row, l) - coefficient * get_content(col, l));
} }
} }
@@ -149,10 +140,11 @@ int main() {
// outputZ(); // outputZ();
// output // output
for (int j = 0; j < n; j++) { // for (int j = 0; j < n; j++) {
printf("%.4lf ", Z[j]); // printf("%.4lf ", Z[j]);
} // }
printf("\n"); // printf("\n");
outputZ();
} }
return 0; return 0;
} }