Doubt about the Farmer and his plot problem.

  1. I’m referring to this question -
    http://www.codechef.com/BOWO2015/problems/RECTSQ.

    My code looked like this:

    #include using namespace std;

    int main() { long int
    i,T,a[1000],b[1000],j; long int
    x,m,l,p,n; cin>>T; for(i=0;i<T;++i)
    cin>>a[i]>>b[i]; for(i=0;i<T;++i)
    {
    n=a[i]b[i];
    if( b[i]>a[i])
    {
    x=a[i];
    a[i]=b[i];
    b[i]=x;
    }
    for(j=b[i];j>=1;–j)
    {
    x=j
    j;
    if(n%x==0)
    break;
    }
    l=n/x;
    cout<<l<<endl;
    }
    return 0; }

    It gave an incorrect answer response
    but I can’t figure out where I went
    wrong. Help would be appreciated.
    Thanks.

Daa the link
http://www.codechef.com/BOWO2015/problems/RECTSQ
no longer exixts…

1 Like

well! eda when you post the code here, you can either post its link, of the solution you have submitted, or you can use this website. http://ideone.com/

But when you paste the code make sure that you select the secret option before running the code.
The problem is i can’t read your code. :frowning: Moreover now the link is not working. And i forgot the question :stuck_out_tongue:

If my memory is right, the logic of the question was

*ans=length/gcd(length,width)width/(gcd(length,width).

I dont remember the exact question da! :frowning: