wojiaocbj

Untitled

Mar 31st, 2023
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.58 KB | None | 0 0
  1. /*
  2.  Author: 曹北健(37509)
  3.  Result: AC Submission_id: 5306417
  4.  Created at: Thu Mar 30 2023 21:09:19 GMT+0800 (China Standard Time)
  5.  Problem: 6799  Time: 5 Memory: 1728
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <math.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14. long long mat[4][4] = { 0 }, submat[3][3] = { 0 };
  15. void copy(int x, int y){
  16.     int i, j, p = 0, q;
  17.     for(i = 0; i < 4; i++){
  18.         if(i == x){
  19.             continue;
  20.         }
  21.         q = 0;
  22.         for(j = 0; j < 4; j++){
  23.             if(j == y){
  24.                 continue;
  25.             }
  26.             submat[p][q] = mat[i][j];
  27.             q++;
  28.         }
  29.         p++;
  30.     }
  31. }
  32. long long det3(){
  33.     return ((submat[0][0] * submat[1][1] * submat[2][2]) + (submat[1][0] * submat[2][1] * submat[0][2]) + (submat[2][0] * submat[0][1] * submat[1][2])) - ((submat[2][0] * submat[1][1] * submat[0][2]) + (submat[1][0] * submat[0][1] * submat[2][2]) + (submat[0][0] * submat[2][1] * submat[1][2]));
  34. }
  35. int main(){
  36.     int i, j;
  37.     for(i = 0; i < 4; i++){
  38.         for(j = 0; j < 4; j++){
  39.             scanf("%lld", &(mat[i][j]));
  40.         }
  41.     }
  42.     copy(0, 1);//M1,2
  43.     printf("%lld\n", det3());
  44.     copy(3, 2);//M4,3
  45.     printf("%lld\n", det3());
  46.     copy(2, 2);//M3,3
  47.     printf("%lld\n", det3());
  48.     copy(0, 3);//M1,4
  49.     printf("%lld\n", det3());
  50.     copy(1, 3);//M2,4
  51.     printf("%lld\n", det3());
  52.     copy(2, 2);//M3,3
  53.     printf("%lld\n", det3());
  54.     copy(1, 1);//M2,2
  55.     printf("%lld\n", det3());
  56.     copy(3, 0);//M4,1
  57.     printf("%lld\n", det3());
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment