摘要:
此算法可以求任意两点的最短距离,其中边权值可以为负数,而dijkstra只能是固定的点间的距离,并且边全值不能为负数。保存的是后面的点(更好)#include#include#includeusing namespace std;#define N 100#define MAX 1000000int... 阅读全文
摘要:
/*排列组合 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1130 Accepted Submission(s): 467Problem Description 有n种物品,并且知道每种物品的数量。要求从中选出m件物品的排列数。例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB","BA"两种。Input 每组输入数据有两行,第一行是二个数n,m(1<=m,n<=10 阅读全文
摘要:
Dijkstra(迪杰斯特拉)算法是典型的最短路径路由算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法能得出最短路径的最优解,但由于它遍历计算的节点很多,所以效率低。 Dijkstra算法是很有代表性的最短路算法,在很多... 阅读全文
摘要:
Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.OutputOutput the approximations of e generated by the above formula for the values of n from 0 to 9. The begi... 阅读全文
摘要:
Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。Output对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。Sample Input2 1 2Sample Output2 7主要是找规律#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>using namespace std;int main(){ int t,ans,n; scanf(&quo 阅读全文
摘要:
/*不容易系列之(4)——考新郎 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12511 Accepted Submission(s): 4740Problem Description 国庆期间,省城HZ刚刚举行了一场盛大的集体婚礼,为了使婚礼进行的丰富一些,司仪临时想出了有一个有意思的节目,叫做"考新郎",具体的操作是这样的:首先,给每位新娘打扮得几乎一模一样,并盖上大大的红盖头随机坐成一排; 然后,让各位新郎寻找 阅读全文
摘要:
/*Binomial Showdown Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15798 Accepted: 4839DescriptionIn how many ways can you choose k elements out of n elements, not taking order into account? Write a program to compute this number. InputThe input will contain one or more test cases. Each 阅读全文
摘要:
/*Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27679 Accepted: 7638DescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive i 阅读全文
摘要:
Happy 2006Time Limit: 3000MSMemory Limit: 65536KTotal Submissions: 6940Accepted: 2192DescriptionTwo positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9...are all relatively prime to 2006. Now your job is easy: for the g. 阅读全文
摘要:
#include#include#include#includeusing namespace std;int main(){int i,a[3]={2,1,3};//sort(a,a+3);//没有这个的话,只能从当前排列。for(int j=0;j#include#include#includeusing namespace std;int main(){ int l,i;char a[15];scanf("%s",a);l=strlen(a);//sort(a,a+l,);//没有这个的话,只能从当前排列。printf("%s\n",a);//必须 阅读全文