Problem - 2986

  之前在华工赛见过的一道简单的模拟,用map轻松干掉。为了精确,要全程用整型比较。轻松1y~

代码如下:

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <map> using namespace std; map<string, int> val; int con(char *str) {
int a, b;
sscanf(str, "%d.%d", &a, &b);
return a * + b;
} bool check(int a, int b, char *p) {
if (!strcmp(p, "=")) return a == b;
if (!strcmp(p, "<=")) return a <= b;
if (!strcmp(p, ">=")) return a >= b;
if (!strcmp(p, "<")) return a < b;
if (!strcmp(p, ">")) return a > b;
return false;
} int main() {
int n, m;
char buf[][];
while (cin >> n >> m) {
for (int i = ; i < n; i++) {
for (int i = ; i < ; i++) cin >> buf[i];
val[buf[]] = con(buf[]);
}
for (int cas = ; cas <= m; cas++) {
int sum = ;
while (true) {
cin >> buf[];
sum += val[buf[]];
cin >> buf[];
if (buf[][] != '+') break;
}
int x;
cin >> x;
cout << "Guess #" << cas << " was " << (check(sum, x * , buf[]) ? "correct." : "incorrect.") << endl;
}
}
return ;
}

——written by Lyon

hdu 2986 Ballot evaluation (Simulation)的更多相关文章

  1. hdu 2986 Ballot evaluation (模拟)

    题目 上次比赛的题目,好长时间了. 这几天感冒了很难受, 直到现在才整理, 上次比赛的时候,出了各种错误,   ,,,样例都没过,题目读的也很差,今天做的时候, 看了一下网上的,发现一个代码特别简洁, ...

  2. HDU 2986 Ballot evaluation(精度问题)

    点我看题目 题意 : 给你n个人名,每个名后边跟着一个数,然后m个式子,判断是否正确. 思路 :算是一个模拟吧,但是要注意浮点数容易丢失精度,所以要好好处理精度,不知道多少人死在精度上,不过我实在是不 ...

  3. Ballot evaluation

    http://acm.hdu.edu.cn/showproblem.php?pid=2986 题意很简单,主要是要处理精度,最手残的是把单词拼写错了... #include <stdio.h&g ...

  4. hdu 4973 A simple simulation problem. (线段树)

    题目链接 题意: 给定n长的序列 m个操作 序列默认为 1, 2, 3···n 操作1:D [l,r] 把[l,r]区间增长 :( 1,2,3,4 进行 D [1,3]变成 1,1,2,2,3,3,4 ...

  5. hdu 4656 Evaluation [任意模数fft trick]

    hdu 4656 Evaluation 题意:给出\(n,b,c,d,f(x) = \sum_{i=1}^{n-1} a_ix^i\),求\(f(b\cdot c^{2k}+d):0\le k < ...

  6. hdu 4190 Distributing Ballot Boxes(贪心+二分查找)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4190 Distributing Ballot Boxes Time Limit: 20000/1000 ...

  7. hdu 4190 Distributing Ballot Boxes 二分

    Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  8. hdu 1057 (simulation, use sentinel to avoid boudary testing, use swap trick to avoid extra copy.) 分类: hdoj 2015-06-19 11:58 25人阅读 评论(0) 收藏

    use sentinel to avoid boudary testing, use swap trick to avoid extra copy. original version #include ...

  9. HDU 4656 Evaluation(MTT)

    题意 \(x_k=bc^{2k}+d\) \(\displaystyle F(x)=\sum_{i=0}^{n-1}a_ix^i\) 给定 \(\{a\},b,c,d,n\) ,求 \(F(x_0), ...

随机推荐

  1. idea 创建properties配置文件

    [转载]原文链接:https://blog.csdn.net/caoPengFlying/article/details/78660379 我们在j2ee当中,连接数据库的时候经常会用到propert ...

  2. LUOGU P2964 [USACO09NOV]硬币的游戏A Coin Game

    题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...

  3. html5之本地数据库

    <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...

  4. 去掉CSS赘余代码,CSS可以更简洁

    本篇文章适合css新手学习,对于已经掌握了css的朋友们也可以通过本片文章来复习知识. 作者通过实践,认为在有些情况下css的代码是可以更加简洁的,多数情况下是因为新手对于一些具有多属性的元素代码不能 ...

  5. 数据ETL是指什么

    ETL是数据抽取(Extract).清洗(Cleaning).转换(Transform).装载(Load)的过程.是构建数据仓库的重要一环,用户从数据源抽取出所需的数据,经过数据清洗,最终按照预先定义 ...

  6. fusion-io工具--更换fusion-ioSSD无法识别及升级指引

    centos6.5系统,(含fusion-io共7块盘)库存的fusion-io卡需要升级固件才能识别 现在只认到6个盘 fdisk -l 2>/dev/null | grep 'Disk /d ...

  7. larbin终于编译完成

    1.目前sourceforge不能下载,只能找mirror进行下载了: 2.一些头文件始终找不到,定位了一下,应该是makefile中设置有问题,把CXXFLAGS中的-I-去掉,即可编译成功:

  8. poj1087&&hdu1526 最大流

    多源多汇. 比较明显的建图.对于电器,可以从源点与各个电器相连,容量为1,表示这个电器有1个,然后对于各种接头,那可以各个接头与汇点相连,容量为1,表示每个接头只能用一次. 然后对于能够相互转换的接头 ...

  9. spider csdn blog part II

    继续上次的笔记, 继续完善csdn博文的提取. 发现了非常好的模块. html2docx 结果展示: 运行之后, 直接生成docx文档. 截个图如下: 结果已经基本满意了!!! 在编写过程中的一些感想 ...

  10. docker的ubuntu镜像无ifconfig和ping命令

    docker的ubuntu镜像无ifconfig和ping命令 或者 ubuntu系统中无ifconfig 和 ping 解决方案: 执行以下鸣冷: apt-get update apt-get in ...