Ballot evaluation
http://acm.hdu.edu.cn/showproblem.php?pid=2986
题意很简单,主要是要处理精度,最手残的是把单词拼写错了。。。
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <map>
using namespace std;
const double eps=1e-;
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)){
map<string,double>p;
p.clear();
string str;
double x;
for (int i = ; i <= n; i++){
cin>>str;
cin>>x;
int tt = int(x*+eps);
p[str] = tt;
}
int o = ;
while(m--){
o++;
int ans = ;
while(){
cin>>str;
if(str==">"||str=="<"||str==">="||str=="<="||str=="=")
break;
ans+=p[str];
}
int k;
cin>>k;
k *=;
int flag1 = ,flag2 = ,flag3 = ,flag4 = ,flag5 = ;
if(str==">"){
if(ans>k)
flag1 = ;
}
else if (str=="<"){
if (ans<k)
flag2 = ;
}
else if (str==">="){
if (ans>=k)
flag3 = ;
}
else if (str=="<="){
if (ans<=k)
flag4 = ;
}
else if (str=="="){
if (ans==k)
flag5 = ;
}
if(flag1||flag2||flag3||flag4||flag5)
printf("Guess #%d was correct.\n",o);
else
printf("Guess #%d was incorrect.\n",o);
}
}
return ;
}
Ballot evaluation的更多相关文章
- hdu 2986 Ballot evaluation (模拟)
题目 上次比赛的题目,好长时间了. 这几天感冒了很难受, 直到现在才整理, 上次比赛的时候,出了各种错误, ,,,样例都没过,题目读的也很差,今天做的时候, 看了一下网上的,发现一个代码特别简洁, ...
- HDU 2986 Ballot evaluation(精度问题)
点我看题目 题意 : 给你n个人名,每个名后边跟着一个数,然后m个式子,判断是否正确. 思路 :算是一个模拟吧,但是要注意浮点数容易丢失精度,所以要好好处理精度,不知道多少人死在精度上,不过我实在是不 ...
- hdu 2986 Ballot evaluation (Simulation)
Problem - 2986 之前在华工赛见过的一道简单的模拟,用map轻松干掉.为了精确,要全程用整型比较.轻松1y~ 代码如下: #include <cstdio> #include ...
- Utility2:Appropriate Evaluation Policy
UCP收集所有Managed Instance的数据的机制,是通过启用各个Managed Instances上的Collection Set:Utility information(位于Managem ...
- SQL SERVER 2012 从Enterprise Evaluation Edtion 升级到 Standard Edtion SP1
案例背景:公司从意大利购买了一套中控系统,前期我也没有参与其中(包括安装.实施都是第三方),直到最近项目负责人告诉我:前期谈判以为是数据库的License费用包含在合同中,现在经过确认SQL Serv ...
- Evaluation Clustering methods
There are many evaluation measures available like entropy, recall, precision, F-measure, silhouette ...
- PLT:说说Evaluation strategy
Brief 在学习方法/函数时,我们总会接触到 按值传值 和 引用传值 两个概念.像C#是按值传值,但参数列表添加了ref/out后则是引用传值,但奇怪的事出现了 namespace Foo{ cla ...
- PyMySQL Evaluation
PyMySQL Evaluation This page will capture issues related to Openstack moving to the PyMySQL driver f ...
- 分配给 主机的 Evaluation Mode 许可证已过期。建议升级许可证。
参考文献 http://247its.wordpress.com/2012/04/02/new-build-esxi-5-complaints-licence-has-expired/ http:// ...
随机推荐
- swift中使用对象归档进行数据本地
对象归档是ios持久化中的其中一种,也是很常用的一种.现在来看看swift是如何实现的.实现要点1),必须实现NSCoding的协议 import UIKit let path=(NSSearchPa ...
- jQuey中的return false作用是什么?
jQuey中的return false作用是什么?在众多的语句中都有return false的使用,当然对于熟悉它的开发者来说,当然是知根知底,知道此语句的作用,当然也就知道在什么时候使用此语句,不过 ...
- swoft| 源码解读系列二: 启动阶段, swoft 都干了些啥?
date: 2018-8-01 14:22:17title: swoft| 源码解读系列二: 启动阶段, swoft 都干了些啥?description: 阅读 sowft 框架源码, 了解 sowf ...
- python list排序(正倒)以及获取重复数据
mylist = [2,2,2,2,5,5,7,2,2,3,3,3,3] #<class 'list'>: [2, 2, 2, 2, 5, 5, 7, 2, 2, 3, 3, 3, 3] ...
- django中配置允许跨域请求
对于django 安装django-cors-headers,详情请看官方文档 pip install django-cors-headers 配置settings.py文件 a.在INSTALLED ...
- circumferential averaged streamwise velocity in ParaView
Goal: get a averaged axial velocity in a circular loop (dashed line in the following figure) Steps: ...
- 在centos7中使用yum安装mysql数据库并使用navicat连接
1.安装 1.查看yum列表,发现没有mysql [root@server-mysql src]# yum list mysql 已加载插件:fastestmirror Repodata is ove ...
- 【Codeforces 242C】King's Path
[链接] 我是链接,点我呀:) [题意] 让你找到(x0,y0)到(x1,y1)的一条最短路 走过的点必须在所给的n个横向路径上 [题解] 因为n条横向路径上的点最多不会超过10的5次方个,所以我们可 ...
- Tensorflow word2vec+manage experiments
Lecture note 5: word2vec + manage experiments Word2vec Most of you are probably already familiar wit ...
- Java并发编程:线程池 - 实例
代码块: public class test { public static void main(String[] args) { test t = new test(); ThreadPoolExe ...