2011年11月10日

摘要: #include <stdio.h>#include <string.h>int n;int prime[168]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239 阅读全文
posted @ 2011-11-10 14:31 Eucalyptus 阅读(3249) 评论(1) 推荐(0) 编辑

2011年11月3日

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>char zhong[1000];char hou[1000];int len;char print[1000][1000];char ptop[1000];struct treenode { int top; char stack[1000]; struct treenode *lchild; struct treenode *rchild;};struct treenode * create(struct treenode *t) { if(t 阅读全文
posted @ 2011-11-03 00:14 Eucalyptus 阅读(217) 评论(0) 推荐(0) 编辑

2011年10月21日

摘要: 这题貌似方法多,效率也不同,先发个水法暴力的(930ms惊险水过):#include <stdio.h>#include <string.h>#include <stdlib.h>int ncase,n,res,tl,tr;char appear[10000];struct node { int l,r,color; struct node *next;};void freelist(struct node * head) { if(head->next==NULL) { free(head); return; } else freelist(head 阅读全文
posted @ 2011-10-21 22:26 Eucalyptus 阅读(186) 评论(0) 推荐(0) 编辑

2011年10月13日

摘要: 思路:找到n=3时,分割数为20,从而可发现2,8, 20之间差的关系正好是6的倍数。代码:#include <stdio.h>int ncase;int n;int nmax;int a[10010];int main() { nmax=1; a[1]=2; scanf("%d",&ncase); while(ncase--) { scanf("%d",&n); if(n<=nmax) { printf("%d\n",a[n]); continue; } else { for (int i=nmax 阅读全文
posted @ 2011-10-13 19:20 Eucalyptus 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 思路:如果 N ,M 存在大于 1 的公约数,则存在漏洞,否则不存在。代码:#include <stdio.h>int gcd (int a,int b) { return b==0? a:gcd(b,a%b);}int ncase,m,n,tmp;int main() { scanf("%d",&ncase); while(ncase--) { scanf("%d%d",&m,&n); if(n>m) { tmp=m; m=n; n=tmp; } if(gcd(m,n)==1) printf("NO\ 阅读全文
posted @ 2011-10-13 17:37 Eucalyptus 阅读(153) 评论(0) 推荐(0) 编辑

2011年10月6日

摘要: 效果图:实现方法:1.窗口的边框的颜色主题更换:打开Tools\ExtensionManager这个扩展管理器,搜索“visualstudiocolorthemeeditor”,我们就能看到一个名为“visualstudiocolorthemeeditor”的扩展,下载安装好这个扩展,重新启动VisualStudio,在View菜单后面就会多出一个Theme菜单来,里面已经预置了几种主题。2.代码着色方案更换:(1)着色方案下载地址:http://studiostyl.es/(2)将下载的方案放到以下目录下:\VisualStudio2010\Settings(3)导入着色方案导入步骤:工具- 阅读全文
posted @ 2011-10-06 17:14 Eucalyptus 阅读(2841) 评论(0) 推荐(0) 编辑

2011年8月13日

摘要: 首先转一篇文章,freopen的用法C语言文件输入/输出ACM改进版(freopen函数)昨天发了一篇《C语言 使用文件输入/输出数据》,使用的是最普通的文件输入/输出方法,Felix大牛随后给了一种更简单的改进方法,在ACM中应用很广,而且超赞,现在来介绍一下。这次用到的文件打开函数不再是fopen,而是stdio.h中包含的另一个函数freopenFILE * freopen ( const char * filename, const char * mode, FILE * stream );【参数说明】filename: 要打开的文件名mode: 文件打开的模式,和fopen中的模式( 阅读全文
posted @ 2011-08-13 17:04 Eucalyptus 阅读(3601) 评论(0) 推荐(0) 编辑

2011年7月24日

摘要: 饿。。思路和实现方法与POJ 1716完全一样。。。但根据北大那本图论书,此题应该有更加优化的建图和约束的方法,因此先丢垃圾桶。。。#include <stdio.h>#include <string.h>#define maxn 150010#define inf 1000000000int head[maxn], pnt[maxn], length[maxn], next[maxn];int tot;int dist[maxn];int queue[10000000];int inq[maxn];int countq[maxn];int n;int a,b,len; 阅读全文
posted @ 2011-07-24 16:37 Eucalyptus 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 建模方法:用数组dist[i]表示从点0到点i-1所包含的关键点的数目;输入数据即可转化为:dist[b+1]-dist[a]>=2 => dist[a]-dist[b+1]<=-2根据实际情况还有两个约束条件:dist[i+1]-dist[i]<=1dist[i+1]-dist[i]>=0 => dist[i]-dist[i]+1<=0于是可以建图,SPFA。最后输出dist[max]-dist[min]即可(max与min 为输入数据出现的最大点和最小点)#include <stdio.h>#include <string.h&g 阅读全文
posted @ 2011-07-24 15:18 Eucalyptus 阅读(405) 评论(0) 推荐(0) 编辑
摘要: 第一次做差分约束系统,关键在于建模。此题的建模很简单, 喜欢:d[j]-d[i]<=len 不喜欢:d[j]-d[i]>=len => d[i]-d[j]<=-len代码:#include <stdio.h>#include <string.h>#define maxn 1010#define maxm 10010#define inf 1000000000int head[maxn], pnt[maxm], length[maxm], next[maxm];int tot;int dist[maxn];int queue[maxn*maxn]; 阅读全文
posted @ 2011-07-24 02:30 Eucalyptus 阅读(553) 评论(0) 推荐(1) 编辑