## InMobi Interview Question

SDE-2s**Country:**India

#include <map>

#include <set>

#include <list>

#include <cmath>

#include <ctime>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <cstdio>

#include <limits>

#include <vector>

#include <cstdlib>

#include <numeric>

#include <sstream>

#include <iostream>

#include <algorithm>

using namespace std;

int main()

{

while(true)

{

long long x,y,n;

cin>>x>>y>>n;

if(x*y<n)

{

cout<<"-1"<<endl;

}

else if(x*y==n)

{

cout<<"0"<<endl;

}

else if((n%x==0 && (n/x)<y) || (n%y==0 && (n/y)<x))

{

cout<<"1"<<endl;

}

else

{

bool f=false;

for(int i=1;i<=sqrt(n);i++)

{

if(n%i==0)

{

int a=i;

int b=n/i;

if((a<=x && b<=y) || (a<=y && b<=x))

{

f=true;

cout<<"2"<<endl;

break;

}

}

if(f==true)

{

break;

}

}

if(f==false)

{

cout<<"-1"<<endl;

}

}

}

return 0;

}

am I missing something in this question ?

- vikas June 02, 2014all you need to find is , if given bar nTiles can be divided by width. if it can be and remainder is less than width , then one break is required.

Otherwise, find two factors , if two integer factors are possible then 2 break are required.