syhd142  
日历
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
统计
  • 随笔 - 23
  • 文章 - 122
  • 评论 - 31
  • 引用 - 0

导航

常用链接

留言簿(2)

随笔档案(23)

文章分类(270)

文章档案(122)

我的豆瓣

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
园划过的格子数可以退出公式,在园内的格子数我也推出了公式,但是后来发现错了,这个要枚举就行了。
两行之间要有空行,最后一组数据不需要,害我多WA了一次。
#include <stdio.h>

int ans[151];

int main()
{
    
int n, a, b;
    
for(int i = 1; i < 151; i++)
    {
        
double r = i - 0.5;
        
int sum = 0;
        
for(int x = 1; x <= i; x++)
        {
            
for(int y = 1; y <= i; y++)
            {
                
if(x * x + y * y < r * r) sum++;
            }
        }
        ans[i] 
= 4 * sum;
    }
    
bool mk = 0;
    
while(~scanf("%d"&n))
    {
        
if(mk) printf("\n");
        mk 
= 1;
        printf(
"In the case n = %d, %d cells contain segments of the circle.\n", n, 8 * n - 4);
        printf(
"There are %d cells completely contained in the circle.\n", ans[n]);
    }
    
return 0;
}
posted on 2010-10-12 10:11 Fucker 阅读(589) 评论(0)  编辑 收藏 引用 所属分类: ACM/ICPC简单

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © Fucker Powered by: 博客园 模板提供:沪江博客