URAL 1263. Elections

33 篇文章 0 订阅

1263. Elections

Time limit: 1.0 second
Memory limit: 64 MB
The next in turn elections are to come soon. All the fences are postered with leaflets and the mail boxes are full of throwaways. Cheeky guys are looking at us from TV’s and promise to make our life better… And programmer Vasechkin is knee-deep in work. He is to write a program that would calculate the results of voting.

Input

The first line contains a number of candidates  N (1 ≤  N ≤ 10000) and a number of electors  M (1 ≤ M ≤ 10000). Then  M lines follow, each one contains a number of candidate that the elector voted for. The candidates are numbered with integers from 1 to  N.

Output

Output  N lines. The  i-th line should contain the percent of electors that voted for the  i-th candidate (to within 2 decimals).

Sample

input output
3 6
1
2
3
2
1
1
50.00%
33.33%
16.67%



题意:统计票数比率。

解析:直接计算即可。



AC代码:

#include <cstdio>

int a[10002];

int main(){
    #ifdef sxk
        freopen("in.txt", "r", stdin);
    #endif //sxk

    int n, m, foo;
    while(scanf("%d%d", &n, &m)==2){
        for(int i=0; i<m; i++){
            scanf("%d", &foo);
            a[foo] ++;
        }
        for(int i=1; i<=n; i++) printf("%.2f%%\n", (float)a[i] / m * 100);
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值