Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健(37509)
- Result: AC Submission_id: 5306417
- Created at: Thu Mar 30 2023 21:09:19 GMT+0800 (China Standard Time)
- Problem: 6799 Time: 5 Memory: 1728
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <ctype.h>
- #include <time.h>
- long long mat[4][4] = { 0 }, submat[3][3] = { 0 };
- void copy(int x, int y){
- int i, j, p = 0, q;
- for(i = 0; i < 4; i++){
- if(i == x){
- continue;
- }
- q = 0;
- for(j = 0; j < 4; j++){
- if(j == y){
- continue;
- }
- submat[p][q] = mat[i][j];
- q++;
- }
- p++;
- }
- }
- long long det3(){
- 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]));
- }
- int main(){
- int i, j;
- for(i = 0; i < 4; i++){
- for(j = 0; j < 4; j++){
- scanf("%lld", &(mat[i][j]));
- }
- }
- copy(0, 1);//M1,2
- printf("%lld\n", det3());
- copy(3, 2);//M4,3
- printf("%lld\n", det3());
- copy(2, 2);//M3,3
- printf("%lld\n", det3());
- copy(0, 3);//M1,4
- printf("%lld\n", det3());
- copy(1, 3);//M2,4
- printf("%lld\n", det3());
- copy(2, 2);//M3,3
- printf("%lld\n", det3());
- copy(1, 1);//M2,2
- printf("%lld\n", det3());
- copy(3, 0);//M4,1
- printf("%lld\n", det3());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment