Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
1 #include <stdio.h> 2 int main() 3 { 4 int n,m; 5 int i,b,sum,t,flag; 6 while (scanf("%d%d",&n,&m)!=EOF) 7 { 8 i=1;b=2;sum=0;t=0;flag=1; 9 while (i<=n) 10 { 11 sum+=b; 12 if(i%m==0) 13 { 14 if(flag==1) 15 { 16 printf("%d",sum/m); 17 flag=0; 18 } 19 else 20 { 21 printf(" %d",sum/m); 22 } 23 sum=0; 24 t=0; 25 } 26 else 27 { 28 t++; 29 } 30 i++; 31 b+=2; 32 } 33 if(t!=0) printf(" %d\n",sum/t); 34 else printf("\n"); 35 } 36 return 0; 37 }
本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/06/03/2533288.html,如需转载请自行联系原作者