Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a, b, c, d, ab, ba, bc, cb, cd, dc, ad, da, bd, db, ac, ca, i, j, n, x, y, z;
- scanf("%d", &n);
- for(i = 1; i <= n; i++){
- for(j = 1; j <= 4; j++){
- scanf("%d %d %d %d", &a, &b, &c, &d);
- if(a == 0){
- ab = b;
- ba = ab;
- ac = c;
- ca = ac;
- ad = d;
- da = ad;
- }
- if(b == 0){
- bc = c;
- cb = bc;
- bd = d;
- db = bd;
- }
- if(c == 0){
- cd = d;
- dc = cd;
- }
- }
- x = ab + bc + cd + da;
- y = ab + bd + dc + ca;
- z = ac + cb + bd + da;
- if(x <= y && x <= z) printf("%d\n", x);
- else if(y <= x && y <= z) printf("%d\n", y);
- else if(z <= y && z <= x) printf("%d\n", z);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement