上一页 1 2 3 4 5 6 7 8 ··· 22 下一页
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4712View Code int N,M;//注意题目说x为正整数,0不算int Extend_euc(int a,int b,int&x,int&y) { if(b==0) {x=1,y=0;return a;} int d=Extend_euc(b,a%b,x,y); int tmp=x; x=y; y=tmp-(a/b)*y; return d;}void modeq(int a,int b,int n) { int e,i,d,x,y,t... 阅读全文
posted @ 2013-05-09 13:05 zhang1107 阅读(119) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showSubmission.do?submissionId=3568082View Code //确定king只有一个后可以在O(N)解决每次询问const int MM = 331630;const int maxn = 31;typedef long long int64;#define debug puts("wrong"); int N,M,Q;char ss[MM][100];set<pair<int,int> >sbt;map<string,int>mp;m 阅读全文
posted @ 2013-05-08 21:57 zhang1107 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: http://acm.fzu.edu.cn/problem.php?pid=1759View 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 N,mod; char str[MM];int64 euler(int64 x) { int64 i, res=x; for(i=2;(i*i)<=x;i++) { if(x%i== 阅读全文
posted @ 2013-05-06 20:06 zhang1107 阅读(135) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1556View Code //区间标记, 当然对于任意修改都能做const int MM = 111111;#define debug puts("wrong")const double lep=1e-10;int N,num[MM];void solve() { int i,j,k,x,y; memset(num,0,sizeof(num)); for(i=0;i<N;i++) { scanf("%d%d",&x,&y); num[x]++, n 阅读全文
posted @ 2013-05-06 19:43 zhang1107 阅读(103) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 22 下一页