摘要: 1, Dijkstra算法(1) 处理正边权…可以处理负边权,但必须是负边只存在源点s连出去的边(2) 时间复杂度……O(V^2)例题:In: 输入包括多组数据。每组数据第一行是两个整数N、M(N#include#includeusing namespace std;#define N 10000#define MAX 100000099int a[N][N];int dist[N];void input (int n,int m){ int p,q,len,i,j; for(i=1;i>p>>q>>len;if(len#define MAX 1000000000 阅读全文
posted @ 2013-09-29 20:20 天天AC 阅读(351) 评论(0) 推荐(0)
摘要: 新生晚会Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6751Accepted Submission(s): 2388Problem Description开学了,杭电又迎来了好多新生。ACMer想为新生准备一个节目。来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法?Input数据的第一行包括一个正整数T,接下来有T组数据,每组数据占一行。每组数据包含两个整数N(来报名的人数,1# includeu 阅读全文
posted @ 2013-09-29 20:16 天天AC 阅读(313) 评论(0) 推荐(0)
摘要: C++版测试代码运行时间(第一种方法)# include# include# include# include# includeusing namespace std;int main(){ srand((unsigned)time(0)); //freopen("d:\\A.in","r",stdin); //freopen("d:\\A.out","r",stdout); int begin,end; begin=clock(); int a,b; scanf("%d %d",&a, 阅读全文
posted @ 2013-09-05 13:46 天天AC 阅读(382) 评论(0) 推荐(0)
摘要: High School/Jr.High 10 PRINT "HELLO WORLD" 20 ENDFirst year in College program Hello(input, output) begin writeln('Hello World') end.Senior year in College (defun hello (print (cons 'Hello (list 'World))))New professional #include void main(void) { char *message[] = {" 阅读全文
posted @ 2013-08-30 18:01 天天AC 阅读(196) 评论(0) 推荐(0)
摘要: void catalan() //求卡特兰数{ int i, j, len, carry, temp; a[1][0] = b[1] = 1; len = 1; for(i = 2; i = 0; j--) //除法 { temp = carry*10 + a[i][j]; a[i][j] = temp/(i+1); carry = temp%(i+1); } while(!a[i][len-1]) //高位零处理 len --; b[i] = len; }} 阅读全文
posted @ 2013-08-28 20:43 天天AC 阅读(431) 评论(0) 推荐(0)
摘要: PillsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 746 Accepted Submission(s): 490Problem DescriptionAunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains N pills.On the first day, she removes a... 阅读全文
posted @ 2013-08-28 20:39 天天AC 阅读(274) 评论(0) 推荐(0)
摘要: ScoreTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 778 Accepted Submission(s): 340Problem Description大家都知道,pfz是“成电杰出学生”,在成电杰出学生的颁奖典礼上,lxh和pfz都没有听台上在说什么,而是在下面讨论当晚的美式足球比赛,lxh预测说纽约巨人队今晚将会得到11分,pfz马上说不可能。因为通常来说美式足球比赛的得分只有3分和7分两种形式,无论怎么得分都不可能得到11分... 阅读全文
posted @ 2013-08-28 20:34 天天AC 阅读(188) 评论(0) 推荐(0)
摘要: /* C,翻译自 C++ 代码 */# include # includeusing namespace std;const int maxCount = 100;//程序允许的最多珠子数//FILE *fin, *fout;//输入输出文件指针int n;//珠子数int v[maxCount * 2];//v[i]表示第(i % n)颗珠子的能量,%表示求余int energy[maxCount * 2][maxCount * 2];//energy[i][j]表示从第i颗珠子到第j颗珠子组成的珠子片断能够得到的最大能量//初始化void init(){ //fopen ( "e 阅读全文
posted @ 2013-08-10 16:04 天天AC 阅读(326) 评论(0) 推荐(0)
摘要: Time Limit: 1000 MSMemory Limit: 65536 KTotal Submit: 70(43 users)Total Accepted: 50(40 users)Rating:Special Judge: NoDescription从m个不同元素中取出n (n ≤ m)个元素的所有组合的个数,叫做从m个不同元素中取出n个元素的组合数。组合数的计算公式如下:C(m, n) = m!/((m - n)!n!)现在请问,如果将组合数C(m, n)写成二进制数,请问转这个二进制数末尾有多少个零。Input第一行是测试样例的个数T,接下来是T个测试样例,每个测试样例占一行,有两 阅读全文
posted @ 2013-08-10 15:56 天天AC 阅读(357) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #define RE(x) (x)^1#define INF 0x3fffffff#define MAXN 205using namespace std;int N, M, G[MAXN][MAXN], dis[MAXN*MAXN];int dir[2][2] = {0, 1, 1, 0};int idx, head[MAXN*MAXN];const int sink = MAXN*MAXN-1, source = MAXN*MAXN-2;struct Edge{ int v, c... 阅读全文
posted @ 2013-08-02 19:49 天天AC 阅读(166) 评论(0) 推荐(0)