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

Problem - 2986 之前在华工赛见过的一道简单的模拟,用map轻松干掉.为了精确,要全程用整型比较.轻松1y~ 代码如下: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string> #include <map> using namespace std; map<string, int&g…
题目 上次比赛的题目,好长时间了. 这几天感冒了很难受, 直到现在才整理, 上次比赛的时候,出了各种错误,   ,,,样例都没过,题目读的也很差,今天做的时候, 看了一下网上的,发现一个代码特别简洁,学习了一下. 不过,在hdu交的时候,交c++会编译错误,不知道怎么回事,两次了,G++能过. 题意:给n个字符串和它们代表的值,求下面m个式子是否成立. 字符串对应的值有一位小数, 式子上的值是整数 (比赛的时候根本 没注意这个) #include <iostream> #include <…
点我看题目 题意 : 给你n个人名,每个名后边跟着一个数,然后m个式子,判断是否正确. 思路 :算是一个模拟吧,但是要注意浮点数容易丢失精度,所以要好好处理精度,不知道多少人死在精度上,不过我实在是不怎么会处理精度,所以我就让那个数变为字符串输入然后在处理,相当于乘上10,但是直接乘上10,数容易变,不知道的自己可以试一下. #include <iostream> #include <string.h> #include <stdio.h> #include <s…
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; ; int…
题目链接 题意: 给定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 ) 操作2:Q [l,r] 问区间[l,r] 上出现最多次数的数 的次数 分析: 会线段树,但是做题的时候没想到如何把这个处理,这是问题的关键. 当时比赛的时候卡了一题,然后快结束的时候看的这个题,所以很乱,没有想出来. 赛后, 我自己有写了一遍,但是我很sb的吧中间的一个变量写错了,结果错了好几…
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 < n\) 取模\(10^6+3\) 昨天刚看过<具体数学>上求和一章 代入\(b\cdot c^{2k}+d\)然后展开,交换求和顺序,得到 \[ f(k) = \sum_{j=0}^n \frac{b^j c^{2kj}}{j!} \sum_{i=j}^n a_i i! \frac{d^{i-…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4190 Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1065    Accepted Submission(s): 536 Problem Description Today, bes…
Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 756    Accepted Submission(s): 372 Problem Description Today, besides SWERC'11, another important event is taking plac…
use sentinel to avoid boudary testing, use swap trick to avoid extra copy. original version #include <cstdio> #include <algorithm> int main() { //freopen("input.txt","r",stdin); const int MAXSIZE=22, dimSize=20; int bacnums…
题意 \(x_k=bc^{2k}+d\) \(\displaystyle F(x)=\sum_{i=0}^{n-1}a_ix^i\) 给定 \(\{a\},b,c,d,n\) ,求 \(F(x_0),F(x_1),\cdots,F(x_{n-1})\) 思路 设 \(ans_k=F(x_k)\) \[ ans_k=\sum_{i=0}^{n-1}a_i(b\cdot c^{2k}+d)^i \] 二项展开得 \[ ans_k=\sum_{i=0}^{n-1}\sum_{j=0}^{i}a_i{i…