题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12845&courseid=270

解题报告:有m个认给n个人投票,n个认位置是固定的,输入一行字符,X表示会投给这个人,例如X....这个表示会投给第一个人,然后让你分别求出这n个人分别占总

票数的百分之几,如果两个人票数相同,则按照原来固定的顺序。

水题,注意任意一个人投的票要有效的话必须满足至少并且只能投一个人。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
struct node
{
char name[];
double num,ans;
int cixu;
}men[];
char str[];
bool cmp(node a,node b)
{
if(a.num == b.num)
return a.cixu < b.cixu;
return a.num > b.num;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i = ;i < n;++i)
{
scanf("%s",men[i].name);
men[i].num = ;
men[i].cixu = i;
}
strcpy(men[n].name,"Invalid");
int tt = m;
while(tt--)
{
scanf("%s",str);
int f = -;
for(int i = ;i < n;++i)
if(str[i] == 'X')
{
if(f == -) f = i;
else f = n;
}
if(f == -) f = n;
men[f].num++;
}
for(int i = ;i <= n;++i)
men[i].ans = 100.0 * men[i].num / (double)m;
sort(men,men+n,cmp);
for(int i = ;i <= n;++i)
printf("%s %.2lf%%\n",men[i].name,men[i].ans);
}
return ;
}

HNU 12845 Ballot Analyzing Device的更多相关文章

  1. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  2. LuoguP7080 [NWRRC2013]Ballot Analyzing Device 题解

    Content 有 \(n\) 名选手参加一个比赛,有 \(m\) 个人为他们投票.第 \(i\) 个人的投票情况用一个长度为 \(n\),并且仅包含 . 和 X 两个字符的字符串,其中,如果第 \( ...

  3. Codeforces Gym 100269A Arrangement of Contest 水题

    Problem A. Arrangement of Contest 题目连接: http://codeforces.com/gym/100269/attachments Description Lit ...

  4. Analyzing UI Performance with Systrace 使用systrace工具分析ui性能

    While developing your application, you should check that user interactions are buttery smooth, runni ...

  5. Xcode 9 Analyzing Crash Reports

    Analyzing Crash Reports After you distribute your app for testing by using TestFlight or after you m ...

  6. Android 性能优化(25)*性能工具之「Systrace」Analyzing UI Performance with Systrace:用Systrace得到ui性能报告

    Analyzing UI Performance with Systrace In this document Overview 简介 Generating a Trace  生成Systrace文件 ...

  7. Android 性能优化(6)网络优化( 2) Analyzing Network Traffic Data:分析网络数据

    Analyzing Network Traffic Data 1.This lesson teaches you to Analyze App Network Traffic Analyze Netw ...

  8. Understanding and Analyzing Application Crash Reports

    Introduction When an application crashes, a crash report is created and stored on the device. Crash ...

  9. Dynamic device virtualization

    A system and method for providing dynamic device virtualization is herein disclosed. According to on ...

随机推荐

  1. Mininet的安装与卸载

    1.Mininet的卸载比较简单,只需要执行以下命令: sudo rm -rf /usr/local/bin/mn /usr/local/bin/mnexec /usr/local/lib/pytho ...

  2. hello-weapp 微信小程序最简示例教程

    打开微信小程序官方开发文档,最好全篇看一遍,基本上就会了. 点击文档中 工具 选项卡中 下载工具页面 下载对应系统版本的微信开发者工具 注意:脱离微信开发者工具是不能调试的 好了,安装下工具即可打开, ...

  3. [BZOJ1856][SCOI2010]字符串(组合数学)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1856 分析:http://www.cnblogs.com/jianglangcaiji ...

  4. SequoiaDB 系列之三 :SequoiaDB的高级功能

    上一篇简单描述了一下SequoiaDB的简单CRUD操作,本篇将讲述一下稍微高级点的功能. 部署在我机器上的集群环境,在经过创建名字为"foo"的cs,创建名字为"bar ...

  5. 解决 SQL Server Profiler 跟踪[不断]出现检索数据

    问题简单回顾: 当我们使用SQL Server Profiler根据数据时,有时刚打开什么也没干呢,就显示很多数据了,当我们用橡皮擦清除,没过两秒就又有了,如图: 是不是很恼火!~不怕,解决方案如下: ...

  6. 练习一_使用Git进行代码管理的心得

    2015年9月19日,第一次软工实践课.助教给我们介绍了git,GitHub.显而易见,我并没有听懂.所以整个上午都在找教程,一个字一个字对着敲,然后敲着敲着就出错,回宿舍,继续敲,也是一样的... ...

  7. Action+Service +Dao三层的功能划分

    来源:http://blog.csdn.net/inter_peng/article/details/41021727 1. Action/Service/DAO简介: Action是管理业务(Ser ...

  8. localStorage和sessionStorage的区别

    //在chrome测试的结果; 知识点1:localStorage和sessionStorage的区别; localStorage生命周期是永久,这意味着除非用户显示在浏览器提供的UI上清除local ...

  9. 解决启动Biee控制台乱码问题

    在安装完Biee后,大家都可以看到在程序中可以找到启动BI服务的地方 点击上图中的启动bi服务则在window系统中会弹出一个dos窗口,来显示执行启动服务的操作,如下图 上图显示的是正常情况,本人安 ...

  10. BZOJ-2002 弹飞绵羊 Link-Cut-Tree (分块)

    2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit: 10 Sec Memory Limit: 259 MB Submit: 6801 Solved: 3573 [Submi ...