An Interest In:
Web News this Week
- March 15, 2024
- March 14, 2024
- March 13, 2024
- March 12, 2024
- March 11, 2024
- March 10, 2024
- March 9, 2024
February 22, 2022 03:54 pm GMT
Original Link: https://dev.to/thivyaamohan/263-abeautiful-matrix-codeforces-solution-477p
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<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;
Original Link: https://dev.to/thivyaamohan/263-abeautiful-matrix-codeforces-solution-477p
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To