// // main.cpp // model e // // Created by Nasca Sergiu Alin on 12/02/16. // Copyright © 2016 Nasca Sergiu Alin. All rights reserved. // #include #include #define INF 1<<30 typedef struct { int x,y; }Punct; int a[201][201]; void flushBuffer() { std::cout<<"\n"; std::cout.flush(); } bool comparePoints(Punct A,Punct B) { if(A.x == B.x && A.y == B.y)return true; return false; } bool signPoints(Punct A, Punct B) { if( a[A.x][A.y] * a[B.x][B.y] >= 0 )return true; return false; } Punct binarysearch(Punct A, Punct B) { Punct mij; while(true) { mij.x = (A.x + B.x)/2; mij.y = (A.y + B.y)/2; if(mij.x<0)mij.x = 0; if(mij.y<0)mij.y = 0; if(comparePoints(mij, A) || comparePoints(mij, B))break; std::cout<>a[mij.x][mij.y]; if(signPoints(mij, A))A = mij; else B = mij; } return B; } void divImpera(Punct A,Punct B) { std::cout<>a[A.x][A.y]; std::cout<>a[B.x][B.y]; Punct mij = binarysearch(A, B); divImpera({A.x,mij.y}, {mij.x-1,B.y}); divImpera({mij.x,A.y}, {B.x,mij.y-1}); } int main() { divImpera({0,0}, {199,199}); return 0; }