URAL 1263. Elections
2015-03-07 14:21
531 查看
1263. Elections
Time limit: 1.0 secondMemory 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 numberof 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; }
相关文章推荐
- URAL 1263 Elections
- ural 1263 Elections
- ural==acm==题目分类
- Ural 1001
- 【URAL1031】Railway tickets
- Ural 1031
- ural 1025 Democracy in Danger
- ural 1053 Pinocchio
- URAL 1013. K-based Numbers. Version 3
- ural 1119. Metro
- Ural 1001 Reverse Root 解题报告
- URAL 1209 110100100010000……
- 【BFS】ural 1033
- URAL 1008 Image encoding [BFS]
- Ural 1519 Formula 1
- Ural_1052. Rabbit Hunt
- Ural_1028. Stars(数状数组)
- URAL1056 Computer Net
- ural 1084 Goat in the Garden
- ural 1039 Anniversary Party