上一页 1 2 3 4 5 6 7 8 ··· 44 下一页
摘要: 题目链接当我放弃的时候过了。sb啊,卡常数!!!换了好几个姿势,本来没写预处理,预处理+俩剪枝,尼玛就过了。。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define INF 0x3f3f3f3f 7 #define LL __int64 8 int bag[31][31]; 9 int sum[31]; 10 int dp[1= st + flag) continue;//剪枝就是这两个剪枝 33 if(maxz = st) contin... 阅读全文
posted @ 2013-11-10 11:26 Naix_x 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 题目链接很棒的一个树形DP。学的太渣了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int dp[10001][11]; 8 struct node 9 {10 int u,v,w,next;11 }edge[30001];12 int first[10001],t,flag[10001];13 int n,m;14 void CL()15 {16 t = 0;17 memset(first,-1,sizeof(first));18 m... 阅读全文
posted @ 2013-11-07 13:06 Naix_x 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 题目链接输出路径,搞了一个DFS出来,主要是这里,浪费了好长时间。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int dp[51][1001]; 8 int c[51],v[51],que[51]; 9 int maxz,ti;10 void dfs(int n,int T,int step)11 {12 int i,t1,t2;13 if(n == 0)14 {15 if(maxz = c[n]&&dp[n][T] == dp... 阅读全文
posted @ 2013-11-06 16:09 Naix_x 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 题目链接猜了一个结论,题面跟欧拉函数有关系。 1 import java.util.*; 2 import java.math.*; 3 import java.text.*; 4 import java.io.*; 5 6 public class Main { 7 8 public static void main(String[] args) { 9 Scanner cin = new Scanner(System.in);10 int p[] = new int[1001];11 int prim[] = new int[10... 阅读全文
posted @ 2013-11-05 18:10 Naix_x 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目链接 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 #define INF 2000000000 8 LL p[3001]; 9 int main()10 {11 int i;12 LL a,fa,fb,b,n;13 LL str,mid,end;14 cin>>a>>fa>>b>>fb>>n;15 if(a > b)16 {17 swap(a,b);18 swap(... 阅读全文
posted @ 2013-11-05 16:10 Naix_x 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 题目链接题意理解的有些问题。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL __int64 7 LL p[501001]; 8 int n; 9 int judge(int x,int m)10 {11 int pre = 0,num = 0,i;12 for(i = 0;i m)23 return 0;24 else25 return 1;26 }27 int main()28 {29 int m,i,l;30 LL s... 阅读全文
posted @ 2013-11-04 17:17 Naix_x 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 记忆化就可以搞定,比赛里都没做出来,真的是态度有问题啊。。。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 double p[1001]; 7 double dp[1001]; 8 int flag[1001],n; 9 double po(double a,int k)10 {11 double b = 1.0;12 while(k)13 {14 if(k&1)15 b = a*b;16 a = a*a;17 k... 阅读全文
posted @ 2013-11-04 11:02 Naix_x 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题目链接队内赛里,匆匆忙忙写的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int v[30]; 10 int flag[30]; 11 int o[30][30]; 12 int p[30]; 13 char name[51]; 14 char fa[51]; 15 int que[6][30]; 16 int s[6]; 17 int sf[30]; 18 int key[6]; 19 int ma... 阅读全文
posted @ 2013-11-03 18:38 Naix_x 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 题目链接很多小的细节都没想到。。。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int p[100001]; 7 int o[100001]; 8 int main() 9 {10 int n,i,flag = 1,j;11 scanf("%d",&n);12 for(i = 0;i 4)24 {25 memset(o,0,sizeof(o));26 for(i = 0;i < n;i ++)27 {28 ... 阅读全文
posted @ 2013-11-01 10:42 Naix_x 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目链接我看错题了。。。都是泪啊,不存在3*4^2这种情况。。。系数必须为1。。。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 int num[60]; 8 LL dp[60][60]; 9 int k,b;10 LL dfs(int pos,int pre,int bound)11 {12 int i,end;13 LL ans = 0;14 if(pos == -1)15 return pre == 0;16 ... 阅读全文
posted @ 2013-10-31 18:21 Naix_x 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 水题。好久没有写过优化搜索题了。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char str[31][31]; 7 int r[31][31]; 8 int c[31][31]; 9 int judge(int rx,int ry,int lx,int ly)10 {11 int i,j;12 for(i = lx;i = 1;i --)46 {47 for(j = m;j >= 1;j --)48 {49 fo... 阅读全文
posted @ 2013-10-30 17:08 Naix_x 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 挺简单的组合把。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 int flag[1001]; 8 int p[1001]; 9 class LittleElephantAndIntervalsDiv110 {11 public :12 LL getNumber(int M, vector L, vector R)13 {14 LL ans = 1;15 int i,j;16 for... 阅读全文
posted @ 2013-10-30 09:56 Naix_x 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 数位DP的感觉,但是跟模版不是一个套路的,看的题解,代码好理解,但是确实难想。 1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL long long 6 LL dp[31][2][2][2]; 7 int a[31],b[31],c[31]; 8 void fun(int *p,int x) 9 {10 int i;11 for(i = 0; i <= 30; i ++)12 {13 if(x&(1<<i))14 p[i] = 1;15 ... 阅读全文
posted @ 2013-10-30 09:37 Naix_x 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目链接本质上是DP,但是俩变量就搞定了。 1 #include 2 #include 3 #include 4 using namespace std; 5 int p[500001]; 6 bool cmp(int a,int b) 7 { 8 if(a 0)30 p1 = p2 + 1;31 else32 p2 = p1 + 1;33 }34 printf("%d\n",max(p1,p2));35 }36 } 阅读全文
posted @ 2013-10-29 20:19 Naix_x 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 数位DP部分,不是很难。DP[i][j]前i位j个幸运数的个数。枚举写的有点搓。。。 1 #include 2 #include 3 using namespace std; 4 #define LL __int64 5 #define MOD 1000000007 6 int dp[21][21]; 7 int p[21],num; 8 int o[21]; 9 int dfs(int pos,int pre,int bound) 10 { 11 int ans,i,end; 12 ans = 0; 13 if(pos == -1) 14 ... 阅读全文
posted @ 2013-10-28 19:23 Naix_x 阅读(316) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 44 下一页