Challenge of Wisdom Time Limit: 2 Seconds      Memory Limit: 32768 KB Background "Then, I want to know whether you're a wise boy!" Problem "I have a great deal of lands. They're divided into N*M grids (N, M <= 1,000,000,000). When you ar…
题意:在一个n * m的地图里,有p个宝藏,每次只能向横纵坐标增加的方向走,问最少走几次能把宝藏都拿走. 解法:按横坐标排序,纵坐标的一个不下降子序列就是一条合法路径,要求多少条不下降子序列可以覆盖所有点,这个问题可以转化为最长下降子序列的长度. 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<string> #include<string.h> #inc…
题目连接:problemId=542" target="_blank">ZOJ 1542 POJ 1861 Network 网络 Network Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Andrew is working as system administrator and is planning to establish a new network in his com…
关于dilworth定理 这里引用一个大神的(http://blog.csdn.net/xuzengqiang/article/details/7266034) 偏序的概念: 设A是一个非空集,P是A上的一个关系,若关系P是自反的.反对称的.和传递的,则称P是集合A上的偏序关系.即P适合下列条件:(1)对任意的a∈A,(a,a)∈P;(2)若(a,b)∈P且(b,a)∈P,则a=b;(3)若(a,b)∈P,(b,c)∈P,则(a,c)∈P,则称P是A上的一个偏序关系.带偏序关系的集合A称为偏序集…
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3795 Description Suppose there are N people in ZJU, whose ages are unknown. We have some messages about them. The i-th message shows that the age of…
Power of Fibonacci Time Limit: 5 Seconds      Memory Limit: 65536 KB In mathematics, Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers of the following integer sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, .…
思路:容易得到s[n]=s[n-1]+s[n-2],也就是fib数. 求第k小的fib质数的也就是第k个质数数-2,当k>2时. 在就是s[n]/x%m=s[n]%(x*m)/x. 代码如下: #include<cstdio> #include<algorithm> #include<cstring> #define ll long long #define M 1000005 using namespace std; ll k,x,m; int prime[M]…
Count the Colors Time Limit: 2 Seconds      Memory Limit: 65536 KB Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can s…
题目链接: POJ:http://poj.org/problem?id=1201 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=508 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.…
题目地址:ZOJ 2588 由于数组开小了而TLE了..这题就是一个求无向连通图最小割边.仅仅要推断dfn[u]是否<low[v],由于low指的当前所能回到的祖先的最小标号,增加low[v]大于dfn[u]时,说明v无法通过其它边回到u之前的点.也就是说v假设想要回到u的祖先点.必需要经过u点,那这条边非常明显就是一条割边.这题还要去重边,假如有重边的话.说明怎么销毁哪条边总能通过还有一条边,所以仅仅要有重边.说明这两点之间没有割边. 代码例如以下: #include <iostream&g…