| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这题考英语,明明的水题啊,贴代码!!算法:暴力模拟
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator