URAL 1263. Elections
来源:互联网 发布:善存多维元素片 知乎 编辑:程序博客网 时间:2024/05/21 19:28
1263. Elections
Time limit: 1.0 second
Memory limit: 64 MB
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
3 6123211
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
- URAL 1263. Elections
- ural 1263 Elections
- URAL 1263 Elections
- Elections
- Evaluating Elections
- A. Elections
- CodeForces570A - Elections
- URAL
- 【ural】
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- 百度地图使用笔记
- 《R语言入门》矩阵元素定义及筛选
- svn报错中文翻译
- Appium Android Bootstrap源码分析之启动运行
- NSOperation
- URAL 1263. Elections
- FFmpeg源代码简单分析:avformat_write_header()
- retain/strong /assign/weak/copy 有什么区别
- Sysstick定时中断实现按键消抖
- NYOJ-1058(搜索)-题目----------------------------- 部分和问题
- Linux网络编程 五种I/O 模式及select、epoll方法的理解
- 《C++语言基础》实践项目——初识对象
- EditText自动换行的问题
- Android几个常用的基本样式