上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 44 下一页
摘要: 题目链接纯纯的数学,以前的时候没想法。。。利用log,果然神奇。。杭电299了。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #define eps 1e-9 5 int main() 6 { 7 int t; 8 __int64 n,a; 9 double k;10 scanf("%d",&t);11 while(t--)12 {13 scanf("%I64d",&n);14 k = n*log10(n);15 阅读全文
posted @ 2012-08-24 09:35 Naix_x 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目链接暴力枚举,a+b+a*b = N,(a+1)*(b+1) = N+1,10^5枚举起来吧。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #define N 1000000000 6 int main() 7 { 8 int i,t,k,num; 9 __int64 n;10 scanf("%d",&t);11 while(t--)12 {13 scanf("%I64d& 阅读全文
posted @ 2012-08-23 20:50 Naix_x 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目链接一开始那个初始化错了,WA了N次啊。。。Vijos上数据太水了,POJ上本来也想水过的,这个感觉将近O(n^4)的复杂度,交上超时了,本来想优化一下预处理出前i个和的,发现好像这个复杂度,找最小的时候,没法优化。。看了DISCUSS,有人就这样水过的,把INT64啥的,小细节改改成了750ms。。。四边形不等式优化,纠结。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 1000000000 5 int p[301]; 6 int dp[31 阅读全文
posted @ 2012-08-23 20:22 Naix_x 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 题目链接有结论。。在有向图中,每两个点都存在一条边,如果存在环,则一定存在3元环。拓扑排序一下。 1 #include <stdio.h> 2 #include <string.h> 3 char str[2001][2001]; 4 int o1[2001],o2[2001],k[2001]; 5 int main() 6 { 7 int t,i,j,num = 0,n,z,nu; 8 scanf("%d",&t); 9 while(t--)10 {11 num ++;12 memset(k,0,sizeof(k));13 ... 阅读全文
posted @ 2012-08-23 11:49 Naix_x 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目链接这个题简单描述一下,就是求最小生成树+最小生成树中源点的最大边,感觉有点贪心,不过还是挺明显的。题意很纠结啊,本来以为只是试着提交以下,居然1Y,看来前面几个题攒人品了。。感觉像是水过的。。。刚一查,是TC上的题。。。表示TC不会玩。。这个题用prim特别好写,kur就应该麻烦了。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <math.h> 5 #define N 100000000 6 int p[101][101],o[101 阅读全文
posted @ 2012-08-22 21:05 Naix_x 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 题目链接递推。。先预处理出小于m的,再推起来。 1 #include <stdio.h> 2 #include <string.h> 3 __int64 p[31]; 4 int main() 5 { 6 int i,j,n,m; 7 while(scanf("%d%d",&n,&m)!=EOF) 8 { 9 if(n == 0&&m == 0)10 break;11 memset(p,0,sizeof(p));12 p[1] = 1;13 for(i = 2;i <= m;i ++)14 ... 阅读全文
posted @ 2012-08-21 20:04 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目链接对这个 真心不太懂,看这了这个博客,这个博客,这个博客,后有点了解原理了。斜率优化也是建立在单调队列的基础上的,以上3个博客讲的很详细。把方程写出来,推导公式才是最主要的问题。。。代码参考题解。 以后再遇到这样的问题慢慢理解吧。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 500001 5 __int64 dp[N],que[N],p[N],sum[N]; 6 int slope(int x,int y) 7 { 8 if(sum[x] == 阅读全文
posted @ 2012-08-20 19:02 Naix_x 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目链接貌似POJ挂了,交题 一直RE。。。我去别的OJ交AC了。当做模版了,查了好几遍,还以为模版敲错了呢。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 1000005 5 int p[N],que[6*N]; 6 int main() 7 { 8 int n,m,i,str,end; 9 scanf("%d%d",&n,&m);10 for(i = 1;i <= n;i ++)11 scanf(" 阅读全文
posted @ 2012-08-19 21:27 Naix_x 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目链接比赛的时侯非常暴力来了个N*M*T的算法,状态方程虽然好想,不会优化。。认真学习一下单调队列优化,看了很多博客+题解,其实原理也不难理解。这个题状态转移,从左边来的 dp[i][j] = dp[i-1][k] + dis(k,j) 先预处理出一个sum数组存每一行前i个元素的和,dp[i][j] = dp[i-1][k] + sum[i][j]-sum[i][k-1];这就可以用单调队列了,在队列首部存放dp[i-1][k]-sum[i][k-1]最大值的下标。明白了原理后,看了一份题解,想了好一会为什么队头总是最大的,问了下学长,这个队列的关键是队头,小的元素可以直接覆盖进入队列,而 阅读全文
posted @ 2012-08-19 17:47 Naix_x 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 怎么感觉这次有点水啊。。3个水。。不过差点悲剧,数组开小了,依旧过了。。。人品吗。。。A乱搞。数组开小,做到最后想hack,意识到自己的数组开小了,没想到居然也过了。。。写的不好WA了次,18分钟。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 1001 5 int p[N]; 6 int main() 7 { 8 int i,n,k; 9 scanf("%d%d",&n,&k);10 for(i = 1;i < 阅读全文
posted @ 2012-08-18 21:52 Naix_x 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 这个帖子链接:http://topic.csdn.net/t/20041217/21/3655691_2.html虽然不是很明白,我现在也纠结是考研还是工作,到真正的该去选择的时候,我觉得一定会做出选择的。PS:05年的帖子确实好久了,不过看得出逛csdn和逛天涯猫扑贴吧的人确实不一样。。。 阅读全文
posted @ 2012-08-18 21:27 Naix_x 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 题目链接多重背包。先按排a[i]好序,然后倒叙多重背包。#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>struct node{ int h,c,a;}bag[401];int cmp(const void *q,const void *b){ return (*(struct node *)q).a > (*(struct node *)b).a ? 1:-1;}int p[401][40001],h[401],c[401],a[401];i 阅读全文
posted @ 2012-08-18 14:25 Naix_x 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目链接无向图啊。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 int o1[510401],o[510401],num; 5 struct node 6 { 7 int flag; 8 struct node *next[26]; 9 }; 10 struct node *build() 11 { 12 int i; 13 struct node *p; 14 p = (struct node *)malloc(sizeof(struct n... 阅读全文
posted @ 2012-08-18 14:21 Naix_x 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接其实这个题不算难。。。可是题意就没搞懂,此题为恰好m件,WA到死啊。初始化为一个很大的负数,就能解决这个问题。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 int p[101][1001]; 6 int ti[101],v[101]; 7 int main() 8 { 9 int t,i,j,n,m,l,k,max;10 scanf("%d",&t);11 while(t--)12 阅读全文
posted @ 2012-08-17 21:15 Naix_x 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题目链接有点BFS的思想,不过还是感觉像是乱搞题。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 200001 5 #define M 10007 6 char str[N]; 7 int p[N]; 8 int main() 9 {10 int i,j,t,n,start,end,ans;11 scanf("%d",&t);12 while(t--)13 {14 scanf("%d%*c",& 阅读全文
posted @ 2012-08-17 19:01 Naix_x 阅读(146) 评论(0) 推荐(0) 编辑
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 44 下一页