hdu 2986 Ballot evaluation (Simulation)
Problem - 2986
之前在华工赛见过的一道简单的模拟,用map轻松干掉。为了精确,要全程用整型比较。轻松1y~
代码如下:
1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <algorithm> 5 #include <string> 6 #include <map> 7 8 using namespace std; 9 10 map<string, int> val; 11 12 int con(char *str) { 13 int a, b; 14 sscanf(str, "%d.%d", &a, &b); 15 return a * 10 + b; 16 } 17 18 bool check(int a, int b, char *p) { 19 if (!strcmp(p, "=")) return a == b; 20 if (!strcmp(p, "<=")) return a <= b; 21 if (!strcmp(p, ">=")) return a >= b; 22 if (!strcmp(p, "<")) return a < b; 23 if (!strcmp(p, ">")) return a > b; 24 return false; 25 } 26 27 int main() { 28 int n, m; 29 char buf[2][100]; 30 while (cin >> n >> m) { 31 for (int i = 0; i < n; i++) { 32 for (int i = 0; i < 2; i++) cin >> buf[i]; 33 val[buf[0]] = con(buf[1]); 34 } 35 for (int cas = 1; cas <= m; cas++) { 36 int sum = 0; 37 while (true) { 38 cin >> buf[0]; 39 sum += val[buf[0]]; 40 cin >> buf[0]; 41 if (buf[0][0] != '+') break; 42 } 43 int x; 44 cin >> x; 45 cout << "Guess #" << cas << " was " << (check(sum, x * 10, buf[0]) ? "correct." : "incorrect.") << endl; 46 } 47 } 48 return 0; 49 }
View Code
——written by Lyon
转载于:https://www.cnblogs.com/LyonLys/p/hdu_2986_Lyon.html
hdu 2986 Ballot evaluation (Simulation)相关推荐
- HDU 4973 A simple simulation problem 线段树
比赛的时候写跪了--赛后拿数据对比才发现,一个地方的判断条件的顺序写反了-- 真是结结实实的坑了队友一把.当时我可以全程都在想这个题,并且有十足的把握想法是对的. 题意: 最开始有n种不同细胞各一个排 ...
- Competitive Programming 3题解
题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...
- Mapping Spiking Neural Networks的论文汇总以及思考
首先感谢CSDN平台,发现不是我一个人在SNN Mapping方面纠结着.去年看了Mapping方面的内容后感觉想创新还是有点难度的,毕竟优化就是生物进化算法类似的套路,可是你会发现自己实现的结果就是 ...
- [论文笔记]CAB:CAching in Buckets CAB-ACME
文章目录 交换机实现 bucket generation bucket generation problem bucket generation algorithm PERFORMANCE EVALU ...
- 23年2月CCF会议截稿8条-SACMAT2023/UAI2023/Euro-Par2023/ASAP2023/ICCCN2023/MobHoc2023/ICCBR2023/PETS2023
点击文末公众号卡片,找对地方,轻松参会 会议简称 截稿时间 通知时间 录用率 官网 SACMAT2023 23.2.17 23.4.12 21年28.6% https://sacmat2023.fbk ...
- 论文阅读--Risk-Resistant Resource Allocation for eMBB and URLLC coexistence under M/G/1 Queueing Model
阅读目的:学习eMBB和URLLC共存下的资源分配/调度等问题 point: 和m/g/1模型关系?-考虑队列时延 risk概念?-考虑了对URLLC delay的细粒度描述,刻画了tailed di ...
- 论文学习--Resource allocation for multi-user downlink MISO OFDMA-URLLC systems
Title:Resource allocation for multi-user downlink MISO OFDMA-URLLC systems Author:Walid R. Ghanem, V ...
- Distributing Ballot Boxes HDU - 4190
问题·: Today, besides SWERC'11, another important event is taking place in Spain which rivals it in im ...
- HDU 4190 Distributing Ballot Boxes【二分答案】
题意:给出n个城市,n个城市分别的居民,m个盒子,为了让每个人都投上票,问每个盒子应该装多少张票 二分盒子装的票数, 如果mid<=m,说明偏大了,r应该向下逼近 ,r=mid 如果mid> ...
最新文章
- 液晶12864COG 液晶模块串口/并口ST7565R带背3.3v 12864-14显示屏
- java中各进制之间的转换(十进制转十六进制、十进制转二进制、二进制转十进制、二进制转十六进制)...
- java回顾之继承 二
- c++ cin不能输入的问题
- [蓝桥杯2016初赛]搭积木-枚举,next_permutation
- linux hash 算法,识别哈希算法类型hash-identifier
- Windows RDP远程桌面无密码账户
- RocketMQ报错:MQClientException:no route info of this topic的解决
- 深入理解java虚拟机 - 垃圾回收机制(GC)
- 完成基于ICX285和ICX205两种CCD的兼容性电路设计
- 一行代码生成Love爱心
- 《Go程序设计语言》- 第10章:包和go工具
- X站全称是什么_科普|HDMI是什么意思?有什么用处?一文带你了解HDMI的发展史...
- Kettle之定时运行Job
- 【他山之石】康师傅的本地化策略
- 【回炉重造】——反射
- Mediapipe 基于KNIFT图标识别demo
- pygame中人物上下左右移动及翻转,背景透明化
- 利用ip-subnet-vlan(基于ip子网划分vlan) 技术 实现一根网线多VLAN业务
- IPHONE 设置 铃声 方法