- 博客(46)
- 收藏
- 关注
原创 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
2016-11-21 22:56:00 272
原创 高斯消元线性方程组
#include #include int main(){ int n,i,j,k; double a[100][100],b[100],x; printf("请输入未知数个数:"); scanf("%d",&n); printf("请输入%d个方程组(未知数系数及等号右边常数):\n",n); for (i = 1;i <= n;i++) for (j = 1;j <=
2016-11-15 18:49:11 184
原创 二叉树链表实现以及遍历
#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_
2016-11-15 14:59:27 716
原创 初谈链表之单链表的实现。
#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
2016-09-23 18:27:08 150
原创 n的阶乘之----大数的阶乘
大数阶乘算法“10000的阶乘怎么算?”“10000”这个数字太大了,无论用什么数据类型保存结果都会溢出。使用数组来模拟数字,这样无论结果数字有多大,只要数组的长度够长就能表示出来。首先定义一个足够长的数组。拿10000的阶乘为例,最后的结果长度是35660位,所以我们定义一个40000个成员的数组就可以了。int result[40000];其核心思想就是把计算结果每一位
2016-09-06 22:46:52 343
原创 二叉树--最大的宽度与高度
题目描述 Description 给出一个二叉树,输出它的最大宽度和高度。输入描述 Input Description第一行一个整数n。下面n行每行有两个数,对于第i行的两个数,代表编号为i的节点所连接的两个左右儿子的编号。如果没有某个儿子为空,则为0。输出描述 Output Description输出共一行,输出二叉树的最
2016-09-06 22:22:37 368 1
原创 二叉树--前序遍历,中序遍历,后序遍历
题目描述 Description求一棵二叉树的前序遍历,中序遍历和后序遍历输入描述 Input Description第一行一个整数n,表示这棵树的节点个数。接下来n行每行2个整数L和R。第i行的两个整数Li和Ri代表编号为i的节点的左儿子编号和右儿子编号。输出描述 Output Description输出一共三行,分别为前序遍历
2016-09-06 22:20:16 232
原创 初谈链表--链表的创建与增加元素删除元素,重新申请长度!
#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
2016-09-06 21:59:07 334
原创 动态分配内存malloc函数之奶牛问题
关于malloc 的持续申请。题目大意:第一年有一头牛,每头牛可以活9年,在第四年的时候开始生小牛,让你输入一个n,求第n年的时候有多少头牛。思路:用malloc函数申请空间。#include #include #include #include #include using namespace std;int main(){ int *c=(int *)malloc
2016-09-06 21:44:53 170
翻译 【全排列】next_permutation函数
按照STL文档的描述,next_permutation函数将按字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止。prev_permutation函数与之相反,是生成给定序列的上一个较小的排列。这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件下面是以前的笔记 与之完全相反的函数还有prev_permutation(1) int 类型的nex
2016-09-02 10:53:39 453
原创 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
2016-08-15 17:02:15 164
原创 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
2016-08-15 16:55:38 271
原创 快速判断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 <=
2016-08-11 16:56:40 193
原创 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
2016-06-25 17:28:32 204
原创 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
2016-06-25 17:19:29 270
原创 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
2016-06-22 20:37:59 400
原创 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
2016-06-22 20:09:57 228
原创 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
2016-06-22 20:03:15 199
原创 POJ - 3620-Avoid The Lakes
DescriptionFarmer John's farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of water. His insurance agency will only repay him,
2016-06-22 15:21:58 155
原创 POJ - 3619-Speed Reading
DescriptionAll K (1 ≤ K ≤ 1,000) of the cows are participating in Farmer John's annual reading contest. The competition consists of reading a single book with N (1 ≤ N ≤ 100,000) pages as fast a
2016-06-22 15:13:26 168
原创 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
2016-06-22 15:07:46 148
原创 ZOJ - 3878-Convert QWERTY to Dvorak
DescriptionEdward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps Lockkey, so Edward never presses the broken Caps Lock key. Luckily
2016-06-22 15:03:40 168
原创 zoj-3880-Demacia of the Ancients
DescriptionThere is a popular multiplayer online battle arena game called Demacia of the Ancients. There are lots of professional teams playing this game. A team will be approved as Level K if the
2016-06-22 15:00:08 264
原创 Pots(bfs恶心的宽搜)
DescriptionYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i)
2016-02-28 22:54:32 299
原创 食物链(并查集)
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个
2016-02-26 18:38:04 205
原创 A Bug's Life(并查集)
DescriptionBackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of
2016-02-26 18:20:52 762
原创 The Suspects(并查集)
Description严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁。为了减少传播给别人的机会, 最好的策略是隔离可能的患者。在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体。同一组的学生经常彼此相通,一个学生可以同时加入几个小组。为了防止非典的传播,NSYSU收集了所有学生
2016-02-26 18:05:39 189
原创 Oil Deposits
DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a gri
2016-02-22 19:37:34 214
原创 迷宫问题
Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上
2016-02-22 19:33:16 235
原创 Find The Multiple
DescriptionGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater t
2016-02-22 19:29:26 152
原创 Catch That Cow
DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point
2016-02-22 19:23:04 263
原创 Dungeon Master
DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one
2016-02-22 17:00:34 332
原创 A-Playing with Paper
DescriptionOne day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origam
2016-02-18 13:08:25 188
原创 The Best Gift
DescriptionEmily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m g
2016-02-18 12:51:26 197
原创 B-Queue on Bus Stop
DescriptionIt's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usua
2016-02-18 12:17:23 253
原创 Factory
DescriptionOne industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory s
2016-02-18 12:11:16 182
原创 Curling 2.0
DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a sq
2016-02-17 18:27:02 207
原创 Uncowed Forces
DescriptionKevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, r
2016-02-17 12:59:47 292
原创 Case of the Zeros and Ones
DescriptionAndrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.Once he thought about a string of length n consisting of
2016-02-17 12:52:50 181
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人