摘要: Problem Description 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值。 Input 测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。 Output 对每个测试用例输出1行,即该表达式的值,精确到小数点后2位。 S... 阅读全文
posted @ 2017-01-17 20:39 Pic 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is th... 阅读全文
posted @ 2017-01-17 17:31 Pic 阅读(278) 评论(0) 推荐(0) 编辑
摘要: Problem Description Recently, lxhgww received a task : to generate strings contain '0's and '1's only, in which '0' appears exactly m times, '1' appears exactly n times. Also, any prefix string of it ... 阅读全文
posted @ 2017-01-17 15:12 Pic 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 组合数C(n,m)在组合数学中占有重要地位。与组合数相关的最重要的两个内容是杨辉三角和二项式定理 1、二项式展开系数和杨辉三角一致 如果求的(a+b)^n所有项的系数? 1、方法一用杨辉三角递推:时间复杂度O(n^2) 2、利用等式C(n,k)=(n-k+1)/k*C(n,k-1),从C(n,0)开始从左到右递推,时间复杂度O(n) 代码: C[0]=1; for(int i=1;i<... 阅读全文
posted @ 2017-01-17 15:07 Pic 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 组合数取模在ACM竞赛中是一个很重要的问题,很多选手因为数据太大而束手无策,今天就来详细讲解它。 组合数取模就是求的值,当然根据,和的取值范围不同,采取的方法也不一样。 接下来,我们来学习一些常见的取值情况 (1)和 这个问题比较简单,组合数的计算可以靠杨辉三角,那么由于和的范围小,直接两层循环即可。 (2)和,并且是素数 这个问题有个叫做Lucas的定理,定理描述是,如果 ... 阅读全文
posted @ 2017-01-17 14:59 Pic 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Lucas定理是用来求 c(n,m) mod p 的值(p为素数) 一般用于求组合数,防止其爆long long Lucas定理:我们令n=sp+q , m=tp+r .(q ,r ≤p) 那么: C(sp+q,tp+r)与C(s,t)*C(q,r)同余 (在编程时你只要继续对 调用Lucas定理即可。 代码可以递归的去完成这个过程,其中递归终点为t = 0 ; 时间O(log... 阅读全文
posted @ 2017-01-17 14:50 Pic 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Problem Description People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1... 阅读全文
posted @ 2017-01-17 14:13 Pic 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-01-17 14:07 Pic 阅读(159) 评论(0) 推荐(0) 编辑