上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 26 下一页
摘要: 刚刚开始想的是用二分的方法做,没想到这个题目这么水,直接暴力就行;代码: 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) 编辑
摘要: 简单的动态规划题,不过题目意思很蛋疼;刚刚开始认为是最长上升子序列,错的一塌糊涂;后来看了斌牛的题解才知道是最长公共子序列;题解:当a[i]==b[j],d(i,j)=(i-1,j-1)+1;else d(i,j)=max(d(i,j-1),d(i-1,j));代码: 1 #include 2 #define maxn 25 3 #include 4 #include 5 using namespace std; 6 int a[maxn],b[maxn],f[maxn][maxn]; 7 int main() 8 { 9 int n,x;10 scanf("%d",&am 阅读全文
posted @ 2013-10-04 23:07 Yours1103 阅读(170) 评论(0) 推荐(0) 编辑
摘要: DescriptionCX老湿经常被人黑,被黑得多了,自己也就麻木了。于是经常听到有人黑他,他都会深情地说一句:禽兽啊!一天CX老湿突发奇想,给大家出了一个难题,并且声称谁能够准确地回答出问题才能继续黑他,否则他就要反击了。这个难题就是:给出两个数p和q,接下来q个询问,每个询问给出两个数A和B,请分别求出:一、有多少个有序数对(x,y)满足1 2 #define maxn 10000001 3 #define ll long long 4 using namespace std; 5 int a,b,cnt[maxn]; 6 ll getans(int l,int r) 7 { 8 ... 阅读全文
posted @ 2013-10-04 16:52 Yours1103 阅读(272) 评论(0) 推荐(0) 编辑
摘要: Description 殷犇有很多队员。他们都认为自己是最强的,于是,一场比赛开始了~ 于是安叔主办了一场比赛,比赛有n个题目,每个题目都有一个价值Pi和相对能力消耗Wi,但是有些题目因为太坑不能同时做出来,并且坑题具有传递性。(a和b一起做会坑、b和c会坑则a和c也会坑) ACM队员们想知道,于是他们想知道在能力范围内,它们最多可以作出多少价值的题目。 聪明的你,告诉我,能帮帮他们吗?Input 第1行两个整数,n,Wmax,k(0 2 #include 3 #include 4 #define maxn 1005 5 using namespace std; 6 7 int f[max.. 阅读全文
posted @ 2013-10-04 13:22 Yours1103 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Description CX是要赶去上课,为了不迟到必须要以最短的路径到达教室,同时CX希望经过的路上能看到的学妹越多越好。现在把地图抽象成一个无向图,CX从1点出发,教室在N号点,告诉每个点上学妹的数量,每条边的长度。请你求出CX以最短路径赶到教室最多能看到多少学妹。Input 多组输入数据(最多20组),输入到文件结束。 每组数据第一行两个正整数N,M其中N代表点的个数(2 2 #include 3 #include 4 #define maxn 1005 5 #define inf 10000000 6 using namespace std; 7 8 int xuemei[maxn]. 阅读全文
posted @ 2013-10-04 13:18 Yours1103 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 字符串处理的题目;学习了一下string类的一些用法;这个代码花的时间很长,其实可以更加优化;代码: 1 #include 2 #include 3 using namespace std; 4 string dict[114]= {"he","h","li","be","b","c","n","o","f","ne" 5 ,"na","mg"," 阅读全文
posted @ 2013-10-03 19:18 Yours1103 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 题目不难,感觉像是一个拓扑排序,要用双端队列来维护;要注意细节,不然WA到死 = =! 1 #include 2 #include 3 #include 4 #define maxn 100005 5 using namespace std; 6 7 int q[2*maxn],count[2][maxn],tail,head,n,m,in[maxn]; 8 vectorve[maxn]; 9 10 int solve(int lab)11 {12 head=tail=n;13 int cnt=0,cc=0,f=lab;14 for(int i=1;i<=n;i++)... 阅读全文
posted @ 2013-10-03 18:01 Yours1103 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 一道字典树异或的题,但是数据比较水,被大家用暴力给干掉了!以前写过一个类似的题,叫做the longest xor in tree;两个差不多吧!好久没写字典树了,复习一下!代码: 1 #include 2 #include 3 #include 4 #define maxn 100010 5 using namespace std; 6 int n,v[maxn],node,next[maxn][2],end[maxn]; 7 8 void add(int cur,int k) 9 {10 memset(next[node],0,sizeof(next[node]));11 ... 阅读全文
posted @ 2013-10-02 22:52 Yours1103 阅读(187) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 26 下一页