hdu 4218 ( IMBA? )

原文地址:http://blog.himdd.com/?p=2286

题意: 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.73205080756887729352744634150587236694280525381038062805580697945193301690

88000370811461867572485756756261414154067030299699450949989524788116555

12094373648528093231902305582067974820101084674923265015312343266903322

88665067225466892183797122704713166036786158801904998653737985938946765

0347506576051, draw a star (‘*’), otherwise draw a blank.
这一大串数字就是sqrt(3);其他的你靠你自己了。

 

//Problem : 4218 ( IMBA? )     Judge Status : Accepted
//RunId : 5779856    Language : C++    Author : himdd
//Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
    //freopen("1.txt","r",stdin);
    int n,r;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&r);
        printf("Case %d:\n",i);
        for(int j=0; j <2 * r+1; j++)
        {
            for(int k=0; k<2 * r + 1; k++)
            {
                if( abs((j-r)*(j-r)+(k-r)*(k-r)-r*r+0.0)<=3 )
                    putchar('*');
                else
                    putchar(' ');
            }
            puts("");
        }
    }
    return 0;
}

 

posted @ 2012-04-19 12:54  Muse牧马  Views(337)  Comments(0Edit  收藏  举报