题目链接: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. [BZOJ 1055][HAOI2008]玩具取名(DP)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1055 分析: 比较难想的dp f[i][j][c]表示i..j能否压缩成字符c 那么怎 ...

  2. Android音乐播放器的开发实例

    本文将引导大家做一个音乐播放器,在做这个Android开发实例的过程中,能够帮助大家进一步熟悉和掌握学过的ListView和其他一些组件.为了有更好的学习效果,其中很多功能我们手动实现,例如音乐播放的 ...

  3. 配置ipvsadm服务

    LVS的三种包转发方式      LVS提供了三种包转发方式:NAT(网络地址映射).IP Tunneling(IP隧道).Direct Routing(直接路由)     不同的转发模式决定了不同的 ...

  4. chromiun 学习《二》 目录结构 +启动流程

    1.chromium的目录结构. 2.先上分析图一张.主要是从BrowserMain进程进行分析的.

  5. 开课选课系统APP基本功能实现

    队员:031302511 031302505 效果图如下:        上述功能分析: 功能分析:我们考虑到手机自带的SQLite会被清理软件清理掉数据,这样就没有实际用处.所以我们就自己搭建服务器 ...

  6. 在Myeclipse buildpath 加server lib (server runtime)/项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved

    来源于:http://blog.csdn.net/dingqinghu/article/details/8805922 http://yl-fighting.iteye.com/blog/140946 ...

  7. C# 域用户操作(转)

    转自:http://www.sobnb.com/u/92/20081406091447.html using System; using System.DirectoryServices;   nam ...

  8. NServiceBus 结合 RabbitMQ 使用

    参考官方教程: Step by Step Guide 新建4个项目: A Console Application named Client A Console Application named Se ...

  9. 表单脚本api_contenteditable

    <html> <head></head> <body> <form> <div contenteditable>ssadas&l ...

  10. poppin_xpower_ 常城