AD1

Friday, 16 June 2017

Beautiful Matrix

Problem 
codeforces.com/problemset/problem/263/A

Solution
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
int main(int argc, char** argv) {
int input;
// read matrix
for(int r=0;r<=4;r++)
{
for(int c=0;c<=4;c++)
{
cin>>input;
if(input==1)
{
cout<<abs(r-2)+abs(c-2)<<endl;
break;
}
}
if(input==1){break;}
}
return 0;
}
view raw beautiful.cpp hosted with ❤ by GitHub


No comments:

Post a Comment