无线网络覆盖 郑州大学第三届acm比赛试题 n 199

 题不难,分好各种情况后再写,一个分类讨论的问题没带优盘,保存一下可怜可怜

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

int main()
{
    int T, length, wide, radius, dia;
    scanf("%d", &T);
    while(T--)
    {
         scanf("%d%d%d", &length, &wide, &radius);
         dia = 2 * radius;
         if(dia <= wide)
             printf("impossible\n");
         else
         {
             double len=sqrt((dia*dia - wide*wide));
             if((len - length) > 0.0)
                      printf("1\n");
             else
             {
                 if(len-1.0 < 0.00001)
                     printf("impossible\n");
                 else
                 {
                     int num;
                     double fnum;
                     fnum = (double)length/len;
                     num = ceil(fnum);
                     printf("%d\n", num);
                 }
                 
             }
             
         }
    }
    return 0;
}


 

posted on 2011-12-01 09:33  java课程设计例子  阅读(153)  评论(0编辑  收藏  举报