题目链接: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. grootJs的属性绑定指令

    index6.html 绑定文本text gt-text="{属性名}" 绑定标签属性attr gt-attr="vm属性名称(标签属性,value表达式)" ...

  2. Cordova4.0 系列 -- 常用命令(2)

    一. 创建一个cordova工程 create <directory> [<id> [<name>]] 二. 列出该工程支持哪些平台 platform [ls | ...

  3. VS2010版快捷键

    VS2010版快捷键 Ctrl+E,D ----格式化全部代码 Ctrl+E,F ----格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O ...

  4. [wikioi1553]互斥的数(数学分析+散列/数学分析+二分)

    题目描述 Description 有这样的一个集合,集合中的元素个数由给定的N决定,集合的元素为N个不同的正整数,一旦集合中的两个数x,y满足y = P*x,那么就认为x,y这两个数是互斥的,现在想知 ...

  5. HDU 5113 Black And White 回溯+剪枝

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5113 Black And White Time Limit: 2000/2000 MS (Java/ ...

  6. java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStreamsJavamail问题

    异常描述如下: Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineI ...

  7. G-nav-04

    'use strict';define([ 'jquery'], function($) { var nav = { init : function() { $("#burger-menu& ...

  8. 全局唯一标识符(GUID)

    全局唯一标识符,简称GUID(发音为/ˈɡuːɪd/或/ˈɡwɪd/),是一种由算法生成的唯一标识,通常表示成32个16进制数字(0-9,A-F)组成的字符串,如:{21EC2020-3AEA-106 ...

  9. Linux_Centos使用mutt+msmtp发送邮件

    一.软件环境 1.centos 6.5 2.msmtp-1.4.32 3.Mutt 1.5.20 (2009-12-10) 二.实现步骤 1.安装配置Mutt $ yum install mutt - ...

  10. FastDFS在.Net平台上的使用

    上一篇,了解了FastDFS是什么东东,一般稍微大一的网站都会做文件分离存储,FastDFS这轻型的分布式文件存储方式,非常有用. 此图片截取博友(张占岭)的勿喷 下面我们就了解一下,FastDFS在 ...