http://acm.hdu.edu.cn/showproblem.php?pid=2986

题意很简单,主要是要处理精度,最手残的是把单词拼写错了。。。

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <algorithm>
 4 #include <stdlib.h>
 5 #include <iostream>
 6 #include <map>
 7 using namespace std;
 8 const double eps=1e-8;
 9 int main()
10 {
11     int n,m;
12     while(~scanf("%d%d",&n,&m)){
13         map<string,double>p;
14         p.clear();
15         string str;
16         double x;
17         for (int i = 1; i <= n; i++){
18             cin>>str;
19             cin>>x;
20             int tt = int(x*10+eps);
21             p[str] = tt;
22         }
23         int o = 0;
24         while(m--){
25             o++;
26             int ans = 0;
27             while(1){
28                 cin>>str;
29                 if(str==">"||str=="<"||str==">="||str=="<="||str=="=")
30                     break;
31                 ans+=p[str];
32             }
33             int k;
34             cin>>k;
35             k *=10;
36             int flag1 = 0,flag2 = 0,flag3 = 0,flag4 = 0,flag5 = 0;
37             if(str==">"){
38                 if(ans>k)
39                     flag1 = 1;
40             }
41             else if (str=="<"){
42                 if (ans<k)
43                     flag2 = 1;
44             }
45             else if (str==">="){
46                 if (ans>=k)
47                     flag3 = 1;
48             }
49             else if (str=="<="){
50                 if (ans<=k)
51                     flag4 = 1;
52             }
53             else if (str=="="){
54                 if (ans==k)
55                     flag5 = 1;
56             }
57             if(flag1||flag2||flag3||flag4||flag5)
58                 printf("Guess #%d was correct.\n",o);
59             else
60                 printf("Guess #%d was incorrect.\n",o);
61         }
62     }
63     return 0;
64 }

View Code

转载于:https://www.cnblogs.com/lahblogs/p/3633338.html

Ballot evaluation相关推荐

  1. hdu 2986 Ballot evaluation (Simulation)

    Problem - 2986 之前在华工赛见过的一道简单的模拟,用map轻松干掉.为了精确,要全程用整型比较.轻松1y~ 代码如下: 1 #include <cstdio> 2 #incl ...

  2. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  3. SDUT2389Ballot evaluation

    这个题就是有一个精度误差的问题 其它还好 题目描述Before the 2009 elections at the European Parliament, Bill and Ted have ask ...

  4. 怎么确定迭代器后面还有至少两个值_JS Lazy evaluation:可迭代对象与迭代器

    本文已经过原作者 MelkorNemesis 授权翻译. Lazy evaluation Lazy evaluation常被译为"延迟计算"或"惰性计算",指的 ...

  5. R语言构建xgboost模型:自定义损失函数(目标函数、loss function、object function)、评估函数(evaluation function)

    R语言构建xgboost模型:自定义损失函数(目标函数.loss function.object function).评估函数(evaluation function) 目录

  6. R语言构建xgboost模型使用早停法训练模型(early stopping):自定义损失函数(目标函数,loss function)、评估函数(evaluation function)

    R语言构建xgboost模型使用早停法训练模型(early stopping):自定义损失函数(目标函数.loss function.object function).评估函数(evaluation ...

  7. A Sequence-Based Novel Approach for Quality Evaluation of Third-Generation Sequencing Reads

    A Sequence-Based Novel Approach for Quality Evaluation of Third-Generation Sequencing Reads 一种基于 序列的 ...

  8. Evaluation of hybrid and non-hybrid methods for de novo assembly of nanopore reads

    Evaluation of hybrid and non-hybrid methods for de novo assembly of nanopore reads 混合和非混合方法对nanopore ...

  9. Comprehensive evaluation of error correction methods for high-throughput sequencing data

    Comprehensive evaluation of error correction methods for high-throughput sequencing data 高通量测序数据误差修正 ...

  10. Evaluation of long read error correction software 长读纠错软件的评估

    Evaluation of long read error correction software Laurent Bouri∗ , Dominique Lavenier† Project-Team ...

最新文章

  1. maven项目的一键构建
  2. 2018中国C++大会精彩回顾
  3. html的canvas标签用法,html5中关于canvas标签用法(绘图)
  4. 信息系统项目管理师论文历年题目2005-2020
  5. 压缩js和css, IIS开启Etags, IIS开启Gzip
  6. Django MTV - 模型层 - (专题)知识要点与实战案例
  7. 查看linux 系统 当前使用的网卡
  8. Spring的p标签
  9. 单片机 MSP430 G2553 F5529 蜂鸣器 音乐 音乐播放器
  10. 世界各国和地区名称代码(GB/T 2659-2000)
  11. 考研数学 第7讲 零点问题和微分不定式
  12. 蓝凌ekp开发_蓝凌EKP在eclipse中启动报错
  13. 【CSDN 年度总结】爱与被爱的双向奔赴——我与《Ta》的点点滴滴
  14. Tomcat服务器的安装使用
  15. shell判断命令是否执行成功
  16. guice使用方法(1)
  17. 实现 OT 算法的开源项目
  18. python龙虎榜数据_GitHub - TR678/stock: stock,股票系统。使用python进行开发。
  19. 商务英语与计算机思维,商务英语技巧的优势
  20. npm太慢, 淘宝npm镜像使用方法

热门文章

  1. 再读 Laravel 5.5 文档
  2. 记录m3u8变成图片的解决办法
  3. 中水处理设备:中水回用的三种主处理方法及其比较
  4. 常见距离算法-欧氏距离、杰卡德距离、余弦距离
  5. 联想微型计算机拆装图解,联想昭阳e43g拆机教程【详细介绍】
  6. 卡莱特led显示屏调试教程_如何使用卡莱特软件点亮LED电子显示屏
  7. 原生JavaScript批量下载文件压缩包
  8. 逆向教程-U3D游戏逆向分析(伊甸逆向分析)
  9. [精华] RDMA技术原理分析、主流实现对比和解析
  10. 一种新的UI测试方法:视觉感知测试