Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题考英语,明明的水题啊,贴代码!!

Posted by zhouzhendong at 2017-03-05 14:09:38 on Problem 3665
算法:暴力模拟
#include <cstdio>
#include <cstring>
int v[1100],n,k,max;
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
		scanf("%d",&v[i]);
	while (k--){
		max=1;
		for (int i=2;i<=n;i++)
			if (v[i]>v[max])
				max=i;
		printf("%d\n",max);
		for (int i=1;i<=n;i++)
			if (i-max)  //等价与if (i!=max)
				v[i]+=v[max]/(n-1);
		int t=v[max]%(n-1);
		for (int i=1;i<=n&&t;i++){
			v[i]++;
			if (i-max)  //等价与if (i!=max)
				t--;
		}
		v[max]=0;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator