sgu 152 分类: sgu 2015-03-16 13:11 35人阅读 评论(0) 收藏
水题
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<iostream>
#include<algorithm>
const int MAXN = 10005;
int n;
int a[MAXN] = {0};
int r[MAXN] = {0};
int sum = 0;
int rem = 0;
int main()
{
#ifndef ONLINE_JUDGE
freopen("sgu152.in","r",stdin);
freopen("sgu152.out","w",stdout);
#endif
scanf("%d",&n);
for(int i = 1 ; i <= n ; i++)
{scanf("%d",&a[i]); sum += a[i];}
for(int i = 1 ; i <= n ; i++)
{
int tmp = a[i]*100;
rem += tmp%sum;
r[i] = tmp/sum;
if(rem >= sum)
{
rem -= sum;
r[i] ++;
}
}
for(int i = 1 ; i <= n ; i++)
printf("%d ",r[i]);
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
}
版权声明:本文为博主原创文章,未经博主允许不得转载。