上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 42 下一页
先记录所有数相乘的质因子,再二分一个x判断x!是否能被M整除View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #define lld __int64 5 lld num[110]; 6 lld a[110],b[110]; 7 void cal(lld n,lld count) 8 { 9 int i,cnt; 10 for(i=2;i*i<=n;i++) 11 { 12 cnt=0; 13 if(n%i==0) 14 ... Read More
posted @ 2011-10-28 16:12 Because Of You Views(334) Comments(0) Diggs(0) Edit
因为两个有重叠的开放时间段的景点不可能在同一天游览完,一天只能游览其中的一个,所以求最大的区间重叠次数就好了View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<iostream> 5 using namespace std; 6 int vis[24*3600+5]; 7 int main() 8 { 9 int n,i,j,s,t;10 while(scanf("%d",&n),n)11 {12 int Read More
posted @ 2011-10-28 13:57 Because Of You Views(246) Comments(0) Diggs(0) Edit
View Code 1 #include<stdio.h> 2 #include<string.h> 3 int map[20][20]; 4 int dx[]={1,1,0,-1,-1,-1,0,1}; 5 int dy[]={0,1,1, 1, 0,-1,-1,-1}; 6 int len=15; 7 int n; 8 bool inside(int x,int y) 9 { 10 return (x>=1&&x<=len&&y>=1&&y<=len); 11 } 12 bool check(i Read More
posted @ 2011-10-28 11:56 Because Of You Views(227) Comments(0) Diggs(0) Edit
//这里lca是要开两倍空间的!!不然显示超时。。。。//因为RMQ&&LCA与郭华阳论文中不太一样,但思想是一样的 1(1) 1 / \ / | \ 2(2) 3(5) 2 3 4 / \ \ / \ 4(3) 5(4) 6(6) 5 6tot :1 2 3 4 5 6 7 8 9 10 11num :1 2 4 2 5 2 1 3 6 3 1(遍历 过程中节点的值)F[] :1 2 4 5 3 6B[] :1 2 3 2 4 2 1 5 6 5 1 深搜的路径中记录的时间... Read More
posted @ 2011-10-27 13:08 Because Of You Views(449) Comments(0) Diggs(0) Edit
表示原来用RMQ和LCA做的方法烦了,现在直接在建最小生成树的过程中建双向边就好了, cost[i][j]表示i到j的最长树边View Code 1 #include<string.h> 2 #include<stdio.h> 3 #include<vector> 4 #include<math.h> 5 #include<queue> 6 using namespace std; 7 const int M =1010; 8 const double inf = 1e20; 9 double max(double a,double Read More
posted @ 2011-10-25 22:02 Because Of You Views(285) Comments(0) Diggs(0) Edit
#include<string.h>#include<stdio.h>#include<math.h>const int MAX=200005;int min(int a,int b){return a<b?a:b;}int dp[MAX][20],a[MAX];int n,k,val[MAX];int LOG[MAX];void Make_Rmq(int n,int b[]){ int i,j; for(i=1;i<=n;i++) dp[0][i]=b[i]; for(i=1;i<=LOG[n];i++) { int limit=n+1- Read More
posted @ 2011-10-25 12:59 Because Of You Views(604) Comments(0) Diggs(0) Edit
二分一个分段数,再用RMQ累加区间最值,跑的好慢哦#include<stdio.h>#include<string.h>const int MAX = 200010;#define min(a,b) a<b?a:b#define max(a,b) a>b?a:bint dp[MAX][30],a[MAX];int k;void init(int n){ memset(dp,0,sizeof(dp)); int i,j,m; for(i=1;i<=n;i++) { dp[i][0]=a[i]; } for(j=1,m=1;m<=n;m<< Read More
posted @ 2011-10-24 18:54 Because Of You Views(724) Comments(0) Diggs(0) Edit
以前的写法太挫了,现在改了一下,精简了View Code #include<stdio.h> #include<string.h> const int MAX = 10010; #define fi(a, b, c) for(int a = (b) ; a < (c) ; a++) #define FI(a, b, c) for(int a = (b) ; a <= (c) ; a++) #define fe(a,b) for(int a=(b); a; a = nxt[a]) int f[MAX],nxt[2*MAX],pnt[2*MAX],h[MAX], Read More
posted @ 2011-10-24 16:37 Because Of You Views(288) Comments(0) Diggs(0) Edit
验一下模板。。。。#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const double eps = 1e-8;const double pi = acos(-1.0);struct Point { double x, y; Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp.y = y - t.y; ... Read More
posted @ 2011-10-20 16:09 Because Of You Views(418) Comments(0) Diggs(0) Edit
有点恶心,线段完全在长方形内,也算相交。。。。还好热心网友发了数据 http://hi.baidu.com/lewutian/blog/item/9a8a38ece87cd52c62d09fb5.html#include<stdio.h>#include<math.h>const double eps = 1e-8;struct Point { double x, y; Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp.y = y - t.y;... Read More
posted @ 2011-10-20 14:30 Because Of You Views(397) Comments(0) Diggs(0) Edit
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 42 下一页