hdu 4218 IMBA?

IMBA?

 

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 893    Accepted Submission(s): 438

 

 

Problem Description

As a kind problem setter, I should warn you, as you may already notice the sample output, it’s a horrible problem and very IMBA (imbalanced).
Today we learn circle, a circle is a simple shape of Euclidean geometry consisting of those points in a plane that are a given distance from a given point, the center. The distance between any of the points and the center is called the radius.
Circles are simple closed curves which divide the plane into two regions: an interior and an exterior. In everyday use, the term "circle" may be used interchangeably to refer to either the boundary of the figure, or to the whole figure including its interior; in strict technical usage, the circle is the former and the latter is called a disk.
A circle can be defined as the curve traced out by a point that moves so that its distance from a given point is constant. A circle may also be defined as a special ellipse in which the two foci are coincident and the eccentricity is 0. Circles are conic sections attained when a right circular cone is intersected by a plane perpendicular to the axis of the cone.
Now let’s draw a circle with your program. Given a radius R, we draw a circle in a (2*R + 1) * (2*R + 1) rectangle, set the center of circle at (R, R) (0-based), for all point, if the square root of the difference between the square of its distance to the center and the square of the radius is less than
1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248575675626141415406703029969945094998952478
81165551209437364852809323190230558206797482010108467492326501531234326690332288665067225466892183797122704713166036786158801904998653737985
9389467650347506576051, draw a star (‘*’), otherwise draw a blank.
Refer to the output for more details. To avoid Presentation Error, you should output exactly the same characters in each row of one test case. The sample output are not completely standard for some non-shown blanks, take care.

 

 

Input

The first line contains a single integer T, indicating the number of test cases.
Each test case contains one integer R.

Technical Specification
1. 1 <= T <= 10
2. 3 <= R <= 18

 

 

Output

For each test case, output the case number in the first line, then a circle required in the description.

 

 

Sample Input

 

2 10 13

 

 

Sample Output

 

Case 1: *** * * * * * * * * * * * * * * * * * * * * * * * * * * *** Case 2: *** * * * * * * * * * * * * * * * * * * * * * * ***

Hint

If you can’t output the sample output, or you get a Wrong Answer and then find your program didn’t output as the sample, please don’t ask me why or talk to your teammate, “IS iSea a SX? Obviously wrong sample! ”, think, and think again.

 

 

/*
题目大意:在一个(2*R+1)*(2*R+1)的矩形框内画一个圆,设置圆心在(R,R)
("0-based"指的是基于0开始,圆心才为(R,R)).
所有的点,如果它到圆心距离的平方与半径平方的差的开方小于或等于根号3,
就输出'*',否则输出空格。
*/ 
//题目中那串数字其实就是根号3
 
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int t;
	cin>>t;
	for(int k=1;k<=t;k++)
	{
		int r;
		cin>>r;
		printf("Case %d:\n",k);
		for(int i=0;i<2*r+1;i++)//圆心(R,R)是基于0起始的,循环变量必须从0开始 
		{
			for(int j=0;j<2*r+1;j++)
			{
				if(abs((i-r)*(i-r)+(j-r)*(j-r)-r*r)<=3)
				  printf("*");
				else printf(" "); 
			}
			printf("\n");
		}
	}
	return 0;
} 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值