Ballot evaluation
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相关推荐
- hdu 2986 Ballot evaluation (Simulation)
Problem - 2986 之前在华工赛见过的一道简单的模拟,用map轻松干掉.为了精确,要全程用整型比较.轻松1y~ 代码如下: 1 #include <cstdio> 2 #incl ...
- Competitive Programming 3题解
题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...
- SDUT2389Ballot evaluation
这个题就是有一个精度误差的问题 其它还好 题目描述Before the 2009 elections at the European Parliament, Bill and Ted have ask ...
- 怎么确定迭代器后面还有至少两个值_JS Lazy evaluation:可迭代对象与迭代器
本文已经过原作者 MelkorNemesis 授权翻译. Lazy evaluation Lazy evaluation常被译为"延迟计算"或"惰性计算",指的 ...
- R语言构建xgboost模型:自定义损失函数(目标函数、loss function、object function)、评估函数(evaluation function)
R语言构建xgboost模型:自定义损失函数(目标函数.loss function.object function).评估函数(evaluation function) 目录
- R语言构建xgboost模型使用早停法训练模型(early stopping):自定义损失函数(目标函数,loss function)、评估函数(evaluation function)
R语言构建xgboost模型使用早停法训练模型(early stopping):自定义损失函数(目标函数.loss function.object function).评估函数(evaluation ...
- 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 一种基于 序列的 ...
- 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 ...
- Comprehensive evaluation of error correction methods for high-throughput sequencing data
Comprehensive evaluation of error correction methods for high-throughput sequencing data 高通量测序数据误差修正 ...
- Evaluation of long read error correction software 长读纠错软件的评估
Evaluation of long read error correction software Laurent Bouri∗ , Dominique Lavenier† Project-Team ...
最新文章
- maven项目的一键构建
- 2018中国C++大会精彩回顾
- html的canvas标签用法,html5中关于canvas标签用法(绘图)
- 信息系统项目管理师论文历年题目2005-2020
- 压缩js和css, IIS开启Etags, IIS开启Gzip
- Django MTV - 模型层 - (专题)知识要点与实战案例
- 查看linux 系统 当前使用的网卡
- Spring的p标签
- 单片机 MSP430 G2553 F5529 蜂鸣器 音乐 音乐播放器
- 世界各国和地区名称代码(GB/T 2659-2000)
- 考研数学 第7讲 零点问题和微分不定式
- 蓝凌ekp开发_蓝凌EKP在eclipse中启动报错
- 【CSDN 年度总结】爱与被爱的双向奔赴——我与《Ta》的点点滴滴
- Tomcat服务器的安装使用
- shell判断命令是否执行成功
- guice使用方法(1)
- 实现 OT 算法的开源项目
- python龙虎榜数据_GitHub - TR678/stock: stock,股票系统。使用python进行开发。
- 商务英语与计算机思维,商务英语技巧的优势
- npm太慢, 淘宝npm镜像使用方法