码迷,mamicode.com
首页 > 其他好文 > 详细

【找规律】URAL - 2065 - Different Sums

时间:2017-02-02 20:06:05      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:找规律   pac   clu   different   name   ural   ...   class   scan   

就让0出现得尽可能多嘛……大概感受一下就是这样……

0 0 ... 0 0 0 0 4 -4 3 -3 2 -2 1 -1

#include<cstdio>
using namespace std;
int n,m,a[510];
int main()
{
	scanf("%d%d",&n,&m);
	int now=0;
	for(int i=n,j=1;i>=1;--i,++j)
	  {
	  	if(m==1)
	  	  a[i]=0;
	  	else
	  	  {
	  	  	now=-now;
	  	  	if(j%2==1)
	  	  	  ++now;
	  	  	a[i]=now;
	  	  	--m;
	  	  }
	  }
	for(int i=1;i<n;++i)
	  printf("%d ",a[i]);
	printf("%d\n",a[n]);
	return 0;
}

【找规律】URAL - 2065 - Different Sums

标签:找规律   pac   clu   different   name   ural   ...   class   scan   

原文地址:http://www.cnblogs.com/autsky-jadek/p/6361480.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!