摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2685 阅读全文
posted @ 2013-05-07 22:47 zhang1107 阅读(88) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1811View Code /*=====================================================*\| Miller Rabin 判断一个大数是不是素数 | Pollard 找出因子\*=====================================================*/#define inf 0x3f3f3f3f#define linf inf*inf#define SS 8//Miller测试次数#define C 240typedef long long ll;ll N, 阅读全文
posted @ 2013-05-07 22:43 zhang1107 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3678典型的2-sat裸题View Code /*====================================================*\| 2-sat问题:判断某个数的0或1的取值是否存在满足条件的解\*====================================================*/const int MM = 222222;int N, M;bool inq[MM];int cur,cnt,belong[MM];int stack[MM], top,dfn[MM], low[MM];int 阅读全文
posted @ 2013-05-07 21:22 zhang1107 阅读(115) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216View Code //复杂度O(sqrt(N)),蛮有意思的const int MM = 11111;typedef long long int64;int64 N;void solve() { int64 i,j,k,sum=0,tmp; scanf("%lld",&N); for(i=1;(i*i)<=N;i++) { tmp=N/i; sum=sum+i*(N/i-N/(i+1)); if(tmp!=i... 阅读全文
posted @ 2013-05-07 20:53 zhang1107 阅读(127) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3221View Code //逆推const int MM = 1111111;#define debug puts("wrong")//typedef __int64 int64;const double lep=1e-10;int N,M, n,m;map<vector<int>,bool>mp;vector<int>st;vector<int>en;void get_data() { int i,j,k 阅读全文
posted @ 2013-05-07 19:13 zhang1107 阅读(197) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3221对于指数取欧拉函数需要注意一下,a^x%P=a^(x%phi(P)+phi(P))%PView Code //A^x = A^(x % Phi(C) + Phi(C)) (mod C) 的应用const int MM = 1111111;#define debug puts("wrong")typedef __int64 int64;const double lep=1e-10;int64 a,b,P,n,mod;const int maxn = 3; //矩阵大小struct Ma 阅读全文
posted @ 2013-05-07 11:16 zhang1107 阅读(180) 评论(0) 推荐(0) 编辑