题目链接: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. Java:静态代理 and 动态代理

    代理模式是常用的设计模式,其特征是代理类与委托类具有相同的接口,在具体实现上,有静态代理和动态代理之分.代理类与委托类之间通常会存在关联关系,一个代理类的对象与一个委托类的对象关联,代理类的对象本身并 ...

  2. 启动tomcat报错 Could not reserve enough space for object heap的解决办法

    问题:打开eclips启动tomcat发现报出Could not reserve enough space for object heap错误. 解决办法:1.首先检查tomcat是否能正常启动.re ...

  3. 第七章 美化DetailView界面

    本项目是<beginning iOS8 programming with swift>中的项目学习笔记==>全部笔记目录 ------------------------------ ...

  4. windows 7 + vs2010 sp1编译 x64位版qt4

    由于qt官方没有发布预编译的64位版qt4,要使用64位版qt4,只能自己编译,编译过程如下: 1,下载源码并解压到D:\qt-src\qt-everywhere-opensource-src-4.8 ...

  5. sqlserver日期函数 dateadd,datediff ,datepart ,datename,convert

    reference:http://www.cnblogs.com/coconut_zhang/archive/2009/02/02/1382598.html http://blog.itpub.net ...

  6. 完美实现开机启动虚拟WIFI,顺便实现目前的WP8系统使用VPN(7.1修)

    众所周知,windows7系统的机器若带有无线网卡(台式机可以买一个USB无线网卡,京东目前39元,TP-Link的),可以虚拟出wifi,供手机等移动设备使用. 虚拟的WIFI的命了和软件在网上都找 ...

  7. Daily Scrum – 1/18

    Meeting Minutes 完成了User Course, 与 Tips 的设计; 修复了一系列Bug; 完成了夜间模式: Burndown Progress part 组员 今日工作 Time ...

  8. java多线程-Semaphore信号量使用

    介绍 信号量(Semaphore),有时被称为信号灯,是在多线程环境下使用的一种设施, 它负责协调各个线程, 以保证它们能够正确.合理的使用公共资源. 概念 Semaphore分为单值和多值两种,前者 ...

  9. iOS边练边学--AFNetWorking框架GET、Post、Download、Upload,数据解析模式以及监控联网状态

    一.AFNETWorking简单使用 get请求 get请求,以后经常用NSURLSession底层的写的部分 简单的post请求 用post请求下载文件,方法很多,还可以通过upload任务来执行 ...

  10. dict内部方法

    代码: #dict内部方法 vdic={'name':'kamil','age':23} print(dir(vdic)) vdic1 = vdic.copy()#copy(self):浅拷贝 pri ...