Problem Description输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。Input输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。Output对于每组输入数据,输出一行,结果保留两位小数。Sample Input0 0 0 1 0 1 1 0Sample Output1.00 1.41 1 #include 2 #include 3 int main() 4 { 5 double x1,y1,x2,y2; 6 while(~scanf("%lf%lf%lf%lf",&x1,&y Read More
posted @ 2013-06-15 21:05 瓶哥 Views(169) Comments(0) Diggs(0) Edit
Problem Descriptions(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数.Input包含多组数据,首先输入T,表示有T组数据.每组数据1行给出n(2 2 #include 3 int mark[1001]={0}; 4 void fun(void) 5 { 6 mark[1]=1; 7 for(int n=4;n1000) break; 19 }20 if(s<1001)21 mark[s... Read More
posted @ 2013-06-15 20:35 瓶哥 Views(276) Comments(0) Diggs(0) Edit
其实printf输出4个数就行。。Problem DescriptionA DFS(digital factorial sum) number is found by summing the factorial of every digit of a positive integer.For example ,consider the positive integer 145 = 1!+4!+5!, so it's a DFS number.Now you should find out all the DFS numbers in the range of int( [1, 2147 Read More
posted @ 2013-06-15 20:31 瓶哥 Views(152) Comments(0) Diggs(0) Edit
暴力5循环解决。。Problem Description=== Op tech briefing, 2002/11/02 06:42 CST ==="The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. Fortunately old Brumbaugh Read More
posted @ 2013-06-15 17:08 瓶哥 Views(165) Comments(0) Diggs(0) Edit
比DFS快了4倍只用10MS就能得出结果。。 1 #include <cstdio> 2 #include <cstring> 3 #include <ctime> 4 const int XSIZE = 3; 5 const int SIZE = XSIZE * XSIZE; 6 const int MAX_C = SIZE * SIZE * 4; //最大列 7 const int MAX_R = SIZE * SIZE * SIZE; //最大行 8 const int MAX_SUDOKU = S... Read More
posted @ 2013-06-14 22:50 瓶哥 Views(296) Comments(0) Diggs(0) Edit
50Ms左右 1 #include <cstdio> 2 #include <cstring> 3 #include <ctime> 4 #include <windows.h> 5 const int XSIZE = 4; //16*16的数独 6 const int _SIZE = XSIZE * XSIZE; 7 const int MAX_SUDOKU = _SIZE * _SIZE; //数独矩阵大小 8 const int MAX_C = _SIZE * _S... Read More
posted @ 2013-06-14 20:58 瓶哥 Views(195) Comments(0) Diggs(0) Edit
这个模版是我从SuDoKu_DLX上面分离出来的,我也是刚接触DLX,总的来说只要能转换为精确覆盖问题的问题,都可以用DLX来解决,而且速度绝对是数一数二的。。。 1 const int SIZE = 16; 2 const int MAX_C = SIZE * SIZE * 4; //最大列 3 const int MAX_R = SIZE * SIZE * SIZE; //最大行 4 const int MAX_LINK = MAX_C * MAX_R; //链表最大范围 5 6 ... Read More
posted @ 2013-06-13 22:32 瓶哥 Views(181) Comments(0) Diggs(0) Edit
Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determi Read More
posted @ 2013-06-12 16:14 瓶哥 Views(181) Comments(0) Diggs(0) Edit
基本BFS搜索Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is Read More
posted @ 2013-06-12 16:13 瓶哥 Views(214) Comments(0) Diggs(0) Edit
1 #include <cstdio> 2 #include <cstdlib> 3 #include <windows.h> 4 #define MaxChild 10 5 typedef char ElemType; 6 typedef struct BiTNode 7 { 8 ElemType data; //节点的数据域 9 struct BiTNode *lchild,*rchild; //左右指针 10 }*BiTree;11 12 void visit(ElemType c,int level) //访问二叉树节点,输出... Read More
posted @ 2013-06-11 23:05 瓶哥 Views(555) Comments(0) Diggs(0) Edit