代码改变世界

两个矩阵相乘!

2012-04-07 21:01 by 璋廊, 421 阅读, 0 推荐, 收藏, 编辑
摘要:/***********两个矩阵相乘;输入n,m分别代表是行、列,接下来是矩阵的元素;输入x、y另一个矩阵的行和列,接下来是矩阵的元素*************/#include<stdio.h>#include<string.h>int main(){ int a[20][20],b[20][20],c[20][20]; int n,m,i,j,k,x,y; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",& 阅读全文

hdu 1258 Sum It Up

2012-04-01 17:13 by 璋廊, 317 阅读, 0 推荐, 收藏, 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1258Problem DescriptionGiven a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t=4, n=6, and the list is [4,3,2,2,1,1], then there are four different sums that equal 4: 4,3+1,2+ 阅读全文

hdu1242 优先队列加广搜

2012-03-28 13:10 by 璋廊, 213 阅读, 0 推荐, 收藏, 编辑
摘要:Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to save Angel. Their task is: approach Angel. We assume that "approach Angel 阅读全文

easy or puzzle ? 字典树

2012-03-27 21:09 by 璋廊, 1043 阅读, 1 推荐, 收藏, 编辑
摘要:Description Laoda最近遇到一个难题,老师交给他很多单词(只有小写字母组成),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input 输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Laoda统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串. 注意:本题只有一组测试数据,处理到文件结束. Output 对于每个提问,给出以该字符串为前缀的单词的数量. Sample Input bananabandbeeabsoluteacmbabbandabcSample O 阅读全文

poj1038

2012-03-27 17:06 by 璋廊, 206 阅读, 0 推荐, 收藏, 编辑
摘要:The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of table 阅读全文

连通图

2012-03-27 16:52 by 璋廊, 273 阅读, 0 推荐, 收藏, 编辑
摘要:http://acm.zzuli.edu.cn/showproblem?problem_id=1243Time Limit:1000MS Memory Limit:65536KTotal Submit:122 Accepted:60Description 给你一个无向图,还有这个图上顶点与顶点之间的边,你能判断这个图连通吗?也就是能否从任意一个点开始可以直接或者间接访问到图上的任何一个顶点。Input首先输入一个整数t,表示有t组例子。 每组例子包括两部分; 第一部分(占一行): 一个整数n和m 表示图的顶点的个数和边的个数。 第二部分 有m行 ,每行两个整数s和t,表示顶点s和t之间有一条边 阅读全文

约瑟夫问题

2012-03-27 16:30 by 璋廊, 933 阅读, 0 推荐, 收藏, 编辑
摘要:Description 据传说,罗马人攻夺Jotapat后,Josephus和朋友两人与其他n个犹太人避难到一个洞穴里。使Josephus非常反感的是,他发现除了他自己和朋友外,其余的都决心殉难以免落入征服者的手中。他不敢太公然表示反对而只好同意了,但他坚持这一行动必须有条不紊地进行,并且建议大家坐成一圆圈,然后从洞口的人开始顺时针报数,数到m的人就杀掉,然后又从下一个人开始从1报数,直到最后一个人去自杀。问Josephus应该把自己和朋友放在第几个位置,才能避免被杀掉。注意:本题要求用链表实现。Input 本题有多组测试数据,第一行是测试数据组数T,下面T行的每一行有两个用一个空格隔开的数n 阅读全文

poj 1503 Integer Inquiry

2012-03-27 16:18 by 璋廊, 172 阅读, 0 推荐, 收藏, 编辑
摘要:DescriptionOne of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these r 阅读全文

poj 1250 Tanning Salon

2012-03-27 12:57 by 璋廊, 190 阅读, 0 推荐, 收藏, 编辑
摘要:Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, thus costing the company a sale. Your task is to write a program that tells the company how many customers left with 阅读全文

求N的阶乘 N!

2012-03-27 12:48 by 璋廊, 255 阅读, 0 推荐, 收藏, 编辑
摘要:#include<stdio.h>#define max 100000;int main(){ int n,i,j; while(scanf("%d",&n)!=EOF) { int a[10008]={0}; a[0]=1; int k=0; for(i=1;i<=n;i++) { for(j=0;j<=k;j++)//两个for循环不能放到一起 a[j]=a[j]*i; for(j=0;j<=k;j++) { ... 阅读全文