ZOJ - 3876-May Day Holiday DescriptionAs a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and
高斯消元线性方程组 #include #include int main(){ int n,i,j,k; double a[100][100],b[100],x; printf("请输入未知数个数:"); scanf("%d",&n); printf("请输入%d个方程组(未知数系数及等号右边常数):",n); for (i = 1;i <= n;i++) for (j = 1;j <=
Anton and Chess 题目链接:http://codeforces.com/problemset/problem/734/D#include #include #include #include #include #include using namespace std;typedef long long LL;const int maxn = 500000 + 20;LL xx0, yy0;s
二叉树链表实现以及遍历 #include #include #include #include using namespace std;#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2typedef int SElemType;#define STACK_
初谈链表之单链表的实现。 #include #include #include #include #define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2typedef int ElemType;typedef int Status;using namespace
n的阶乘之----大数的阶乘 大数阶乘算法“10000的阶乘怎么算?”“10000”这个数字太大了,无论用什么数据类型保存结果都会溢出。使用数组来模拟数字,这样无论结果数字有多大,只要数组的长度够长就能表示出来。首先定义一个足够长的数组。拿10000的阶乘为例,最后的结果长度是35660位,所以我们定义一个40000个成员的数组就可以了。int result[40000];其核心思想就是把计算结果每一位
二叉树--最大的宽度与高度 题目描述 Description 给出一个二叉树,输出它的最大宽度和高度。输入描述 Input Description第一行一个整数n。下面n行每行有两个数,对于第i行的两个数,代表编号为i的节点所连接的两个左右儿子的编号。如果没有某个儿子为空,则为0。输出描述 Output Description输出共一行,输出二叉树的最
二叉树--前序遍历,中序遍历,后序遍历 题目描述 Description求一棵二叉树的前序遍历,中序遍历和后序遍历输入描述 Input Description第一行一个整数n,表示这棵树的节点个数。接下来n行每行2个整数L和R。第i行的两个整数Li和Ri代表编号为i的节点的左儿子编号和右儿子编号。输出描述 Output Description输出一共三行,分别为前序遍历
初谈链表--链表的创建与增加元素删除元素,重新申请长度! #include #include #include #include #include #include using namespace std;#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2#define List_init
动态分配内存malloc函数之奶牛问题 关于malloc 的持续申请。题目大意:第一年有一头牛,每头牛可以活9年,在第四年的时候开始生小牛,让你输入一个n,求第n年的时候有多少头牛。思路:用malloc函数申请空间。#include #include #include #include #include using namespace std;int main(){ int *c=(int *)malloc
【全排列】next_permutation函数 按照STL文档的描述,next_permutation函数将按字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止。prev_permutation函数与之相反,是生成给定序列的上一个较小的排列。这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件下面是以前的笔记 与之完全相反的函数还有prev_permutation(1) int 类型的nex
HDU 3866 Moonfang's Birthday(贪心) DescriptionIt's Moonfang's birthday,and his friends decided to buy him a copy of XianJianQiXiaZhuan V. Since some of friends have more money available than others, nobody has to pay more th
HDU 3310-Volume of a cylinder(积分) DescriptionOne cylinder across another cylinder at right angles, tell the volume of the intersection of the cylinders.InputMultiple test cases, the number of them T is given in the v
快速判断2-m内那些数是素数 int m,d; cin>>m>>d; bool aa[m+1]; aa[2]=true; for(int i = 3;i <= m;i++) { if(i%2) aa[i]=true; else aa[i]=false; } for(int i =3;i <=
Word Amalgamation DescriptionIn millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the
More Cowbell DescriptionKevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k
CodeForces - 637A-Voting for Photos DescriptionAfter celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the socia
FZU - 2214-Knapsack problem DescriptionGiven a set of n items, each with a weight w[i] and a value v[i], determine a way to choose the items into a knapsack so that the total weight is less than or equal to a given limit B a
ZOJ - 3875-Lunch Time DescriptionThe 999th Zhejiang Provincial Collegiate Programming Contest will be held in Marjar University. The canteen of Marjar University is making preparations for this grand competition. The c