356

#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;


int main()
{
	double n,m,d1,d2;
	int cnt,n_cnt,c=0;
	while(cin>>n)
	{
		m=(n-0.5)*(n-0.5);
		cnt=0;
		n_cnt=0;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				d1=i*i+j*j;
				d2=(i+1)*(i+1)+(j+1)*(j+1);

				if(d1<m && d2<=m)
				{
					//cout<<i<<" "<<j<<" "<<i+1<<" "<<j+1<<"\n";
					cnt++;
				}
				else if(d1<m && d2>m)
				n_cnt++;
			}
		}
		if(c)
		cout<<"\n";
		c=1;
		cout<<"In the case n = "<<n<<", "<<4*n_cnt<<" cells contain segments of the circle.\n";
		cout<<"There are "<<4*cnt<<" cells completely contained in the circle.\n";

	}
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *