CAN ANYONE PLEASE TELL ME WHICH TEST CASE IS WRONG .................
 PROBLEM:    https://www.spoj.pl/problems/STREETR/
#include<stdio.h>
main()
{
    long long int n,i,ans,k,flag,m,a[100100],d;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    d=a[1]-a[0];
    m=1;
    while(d>0)
    {
        m=1;
        ans=0;
        flag=1;
        for(i=1;i<n;i++)
        {
            if((a[i]-a[0])%d==0)
            {
            k=(a[i]-a[0])/d+1;
            ans=ans+(k-m-1);
            m=k;
            }
            else
            {
            flag=0;
            break;
            }
        }
        if(flag==0||ans==0)
        d=d-1;
        else
        {
    //        h=0;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}




-- 
UTKARSH SRIVATAV
CSE-3
B-TECH 2nd YEAR
MNNIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to