263 A.Beautiful Matrix | Codeforces Solution

A 5 x 5 matrix is given which contains 24 zeros and 1 ones.

And the matrix is beautiful if the number one is located in the middle.

We need to count the minimum number of moves to make the matrix beautiful.

#include<iostream>
#include<cma…


This content originally appeared on DEV Community and was authored by DEV Community

A 5 x 5 matrix is given which contains 24 zeros and 1 ones.

And the matrix is beautiful if the number one is located in the middle.

We need to count the minimum number of moves to make the matrix beautiful.

#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int c =0;
    for(int i =1;i<=5;i++)
    {
        for(int j=1;j<=5;j++)
        {
            cin>>c;
            if(c == 1){
                cout<< abs(i-3)+abs(j-3)<<endl;
            }
        }
    }
    return 0;


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-02-22T15:54:37+00:00) 263 A.Beautiful Matrix | Codeforces Solution. Retrieved from https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/

MLA
" » 263 A.Beautiful Matrix | Codeforces Solution." DEV Community | Sciencx - Tuesday February 22, 2022, https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/
HARVARD
DEV Community | Sciencx Tuesday February 22, 2022 » 263 A.Beautiful Matrix | Codeforces Solution., viewed ,<https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/>
VANCOUVER
DEV Community | Sciencx - » 263 A.Beautiful Matrix | Codeforces Solution. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/
CHICAGO
" » 263 A.Beautiful Matrix | Codeforces Solution." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/
IEEE
" » 263 A.Beautiful Matrix | Codeforces Solution." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/. [Accessed: ]
rf:citation
» 263 A.Beautiful Matrix | Codeforces Solution | DEV Community | Sciencx | https://www.scien.cx/2022/02/22/263-a-beautiful-matrix-codeforces-solution/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.