摘要: 又是个2-sat的模板题;反正评委的选择必须有一个是正确的,1错误,那么2就必须正确;这就是一个2-sat问题。直接上白书的模板啊,不过稍微要注意的一点是对于第一个点必须要选择,不然就违反了题意;代码: 1 #include 2 #define maxn 2005 3 #define maxm 4005 4 #include 5 #include 6 using namespace std; 7 struct twosat 8 { 9 int n;10 vectorg[maxn*2];11 bool mark[maxn*2];12 int s[maxn*2],c... 阅读全文
posted @ 2013-10-05 19:38 Yours1103 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 比赛的时候刷了一点小聪明,发现这个数列是卢卡斯数,一个递推关系像斐波拉契数列的数列;我不知道怎么证明,如果哪天无意中会证了再加上;这题唯一的难点就是大数运算;直接用JAVA代码: 1 import java.io.PrintWriter; 2 import java.math.BigInteger; 3 import java.util.Scanner; 4 5 public class Main { 6 Scanner scan=new Scanner(System.in); 7 PrintWriter out=new PrintWriter(System.out); 8... 阅读全文
posted @ 2013-10-05 16:30 Yours1103 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 刚刚开始想的是用二分的方法做,没想到这个题目这么水,直接暴力就行;代码: 1 #include 2 #include 3 #define maxn 1000005 4 using namespace std; 5 int num[maxn]; 6 7 int main() 8 { 9 int x,n,y,ma;10 while(scanf("%d",&x)!=EOF)11 {12 ma=x*10000000;13 scanf("%d",&n);14 for(int i=0;ima)y--;22 e... 阅读全文
posted @ 2013-10-05 16:20 Yours1103 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 一个最小费用最大流的简单建模题;比赛的时候和小珺合力想到了这个题目的模型;方法:拆点+边的容量为1这样就可以保证他们不会在点上和边上相遇了!感谢刘汝佳大神的模板,让我这个网络流的小白A了这个题。代码: 1 #include 2 #include 3 #include 4 #include 5 #define maxn 42005 6 #define inf 99999 7 using namespace std; 8 9 struct edge 10 { 11 int from ,to,cap,flow,cost; 12 }; 13 14 struct mcmf ... 阅读全文
posted @ 2013-10-05 15:59 Yours1103 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 一个简单的题;感觉像计算几何,其实并用不到什么计算几何的知识;方法:首先对每条边判断一下,看他们能够把平面分成多少份;然后用边来对点划分集合,首先初始化为一个集合;最后如果点的集合等于平面的份数,就说明每块都有一个士兵;代码: 1 #include 2 #include 3 #define maxn 105 4 #define maxm 50005 5 using namespace std; 6 int a[maxn],b[maxn],c[maxn]; 7 long long x[maxm],y[maxm]; 8 int main() 9 {10 int t,n,m;11 s... 阅读全文
posted @ 2013-10-05 15:52 Yours1103 阅读(227) 评论(0) 推荐(0) 编辑