[恢]hdu 2015

2011-12-14 05:49:09

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2015

题意:中文,忒麻烦了。

代码:

# include <stdio.h>


int main ()
{
int n, m, flag ;
int i, sum, cnt ;
while (~scanf ("%d%d", &n, &m))
{
flag = 0 ;
cnt = 0 ;
sum = 0 ;
for (i = 1 ; i <= n ; i++)
{
sum += i*2 ;
cnt ++ ;
if (cnt == m)
{
if (flag == 0) flag = 1 ;
else printf (" ") ;
printf ("%d", sum/m) ;
cnt = 0 ;
sum = 0 ;
}
}
if (cnt != 0)
{
if (flag == 0) flag = 1 ;
else printf (" ") ;
printf ("%d", sum/cnt) ;
}
printf ("\n") ;
}
return 0 ;
}



posted @ 2012-01-06 14:46  Seraph2012  阅读(178)  评论(0编辑  收藏  举报