/** * 简易四则运算(栈实现) * #include <stack> * #include <cstring> */ std::stack<char> opr; std::stack<double> num; char oprPRI[256]; //初始化调用 void initCalc() { //优先级设置 char oprMap[7][2] = { {'+', 1}, {'-', 1}, {'*', 2}, {'/', 2}, {'^', 3}, {'(', 100}, {')', 0} }; for(int i = 0; i < 7; i

基础函数: // 最大公约数,欧几里得定理 int gcd(int a, int b) { return b?gcd(b, a % b): a; } // 拓展欧几里得定理 // 求解ax + by = gcd(a,b) int ext_gcd(int a, int b, int &x, int &y) { int tmp, ret; if(!b) { x = 1; y = 0;

题目链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=2826 大致意思是给你两条线段,问组成的开口向上的V形区域能盛多少雨水。雨水是垂直落下的。 显然线段不相交,或者平行,重合,或者有一条斜率

关于差分约束(转载) (本文假设读者已经有以下知识:最短路径的基本性质、Bellman-Ford算法。) 比如有这样一组不等式: $$ \begin{cases} X1 - X2 <= 0 \\

一、引言 计算机的出现使得很多原本十分繁琐的工作得以大幅度简化,但是也有一些在人们直观看来很容易的问题却需要拿出一套并不简单的通用解决方案,比

好久不写代码,省赛之后一直在赶作业和复习。对自己还真没什么信心 话说回来试了一下联系赛 三道水题,虽然钱两题很快,但是竟然多敲了几个没用的字符导

int a = 12345678; //格式为sring输出 Label1.Text = string.Format("asdfadsf{0}adsfasdf",a); Label2.Text = "asdfadsf"+a.ToString()+"adsfasdf"; Label1.Text = string.Format("asdfadsf{0:C}adsfasdf"

树状数组模块 ACM个人模板 POJ 2155 题目测试通过 /** * 树状数组模块 * 下标从0开始 */ typedef long DG_Ran; typedef long DG_Num; const DG_Num DG_MAXN = 1005; //2^n DG_Num LowBit(DG_Num n) { return n & (-n); } //获取父节点索引 DG_Num DGFather(DG_Num n)

/** * 线性筛法求素数表 * 复杂度: O(n) */ const long MAXP = 1000000; long prime[MAXP] = {0},num_prime = 0; int isNotPrime[MAXP] = {1, 1}; void GetPrime_Init()//初始化调用 { for(long i = 2 ; i < MAXP ; i ++) { if(!

又是我们的OJ 题目链接: http://www.cn210.com/onlinejudge/problemshow.php?pro_id=92 Description tancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only one problem - Petru has locked the spacecraft with a sophisticated cryptosystem based on the ID numbers of the stars

http://www.cn210.com/onlinejudge/problemshow.php?pro_id=98 我们的OJ Description &nbsp;</center> Input The next line contains the numbers of&nbsp;S:&nbsp;x1,&nbsp;x2, ...,&nbsp;xn.&nbsp; It is known that each&nbsp;xi&nbsp;is an integer, 0 &le;&nbsp;xi&nbsp;&le; 2*109.&nbsp; The input data set is correct and ends with an end of file.&nbsp;</div> Output &nbsp; Sample Input 2 1 2 3 1 3 9 4 1 2 3 6 Sample Output 1 12 4 首先由于行列式交换

题目链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=2976 0-1分数规划 最优比例生成树 迭代法 证明:(前几次都是看别人的,这次自己证明) 对于集合s,令l* = max{ a(x) / b(x) } = a(x*) / b(x*).l为