摘要:#pragma warning(disable:4786)#include#include#include#includeusing namespace std;int gOrient[4][2] = {-1,0, 1,0, 0,-1, 0,1};//-----------------------------------------------------------------------------class State{public: int findPos(int n) const; bool operator calculated; priority_queue ...
阅读全文
摘要:#pragma warning (disable: 4786)#include#include#include#include#include#includeusing namespace std;#ifdef _WIN32typedef unsigned __int64 UINT64;#eliftypedef unsigned long long UINT64;#endif//1000以内素数表UINT64 gPrimeTable1000[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
阅读全文
摘要:double dijkstra(int src, int dest, vector& path, vector >& adjT){ if (src = adjT.size() || dest = adjT.size()) return -1; map previous; //记录最短路径上每个点的前驱点 set V; //未计算的点 map distance; //记录src到各顶点的距离 int i; for (i=0; i::const_iterator it = adjT[src].find(i); if (it != ad...
阅读全文
摘要:计算机想一个不重复的四位数,人来猜.每次计算机告诉数也对,位置也对的数的个数和数对但位置不对的个数.例如计算机想的是3194,人猜的是1234,则计算机输出2 1.人需要在8次之内猜出来.编这样的程序很简单,可是问题反过来,人想一个数,让计算机在8次之内猜出来. 这个问题就难的多的多了.我在大三时候想出了下面的办法:#include#include#includeint P[5040][5],record[8][2],T,num=5040,A,B,ans[4],key[4],next,guess[8][4], judgetype[14][3]={{0,0},{0,1},{0,2},{0,...
阅读全文