Poj Solution 1648

http://poj.org/problem?id=1648

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>


#define INF 30000
#define NMAX 13
float N,E,W;
double gety(double x)
{
    return (E-W)/N*x+W;
}
void solve()
{
    int i,j;
    int sum=0;
    double(y);
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            for(int p=0;p<2;p++)
            {
                y=gety(i+p);
                if(y>=j&&y<=j+1)
                {
                    sum++;
                    break;
                }
            }
        }
    }
    printf("%d",sum);
}
int main()
{

#if _DEBUG    
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    scanf("%f%f%f",&N,&E,&W);
    E=E/100;
    W=W/100;
    solve();
#if _DEBUG
    fclose(stdin);
    fclose(stdout);
#endif
    return 1;
}
											
This entry was posted in poj. Bookmark the permalink.