雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 50 下一页

2011年9月5日

摘要: 患病的奶牛N只,D种病毒,最多包含K种病毒,求包含最多有几头牛6 3 201 11 21 32 2 12 2 1看到D的范围比较小<=15,用011,表示患了第2,3钟病毒的奶牛a[i]在枚举K种病毒,如110 (用STL里的排列函数枚举)m如m|a[i]==m,说明a[i]包括在m里,add++记录最大值View Code #include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>using namespace std;int a[1009];bool 阅读全文

posted @ 2011-09-05 21:09 huhuuu 阅读(200) 评论(0) 推荐(0) 编辑

2011年9月2日

摘要: 先将数据插入到一颗二叉树中,再中序遍历该树View Code #include<stdio.h>#include<string.h>#include<iostream>using namespace std;struct data{ int l,m,r;}node[100090];int add,ok=0;;void insert(int c,int root){ if(c>node[root].m)//óò { if(node[root].r==-1) { node[root].r=add; node[... 阅读全文

posted @ 2011-09-02 21:34 huhuuu 阅读(392) 评论(1) 推荐(0) 编辑

2011年9月1日

摘要: 题意:N头牛 公牛与公牛之间最小间隔K头母牛之前用排列组合的方法去思考,数据大,不能解i<=kf[0]=i+1当i头牛是母牛时,没什么限制,f[i]+=f[i-1]当i头是公牛时,之前要有K头奶牛,f[i]+=f[i-k-1]View Code #include<stdio.h>int dp[100009];int main(){ int n,k; while(scanf("%d%d",&n,&k)!=EOF) { int i; for(i=0;i<=n;i++) { if(i<=k) ... 阅读全文

posted @ 2011-09-01 21:15 huhuuu 阅读(170) 评论(0) 推荐(0) 编辑

2011年8月30日

摘要: 比赛的时候,想到用表的方法进行统计,但是直到最后还是没敢敲先打表生成一个幸运数的表再枚举幸运数的表进行统计注意打表时会超int,果断__int64View Code #include<iostream>#include<algorithm>using namespace std;__int64 pl,pr,vl,vr,k;__int64 len=0;__int64 c[10009];void dfs(__int64 n)//生成4,7...的表{ if(n>pr&&n>vr) return; c[len]=n; len++; dfs(n*10 阅读全文

posted @ 2011-08-30 16:06 huhuuu 阅读(270) 评论(0) 推荐(0) 编辑

2011年8月29日

摘要: 上届:最大的饼的面积下届:0二分。。。注意的是while条件与整数的二分查找有区别(r-l)>0.00001取PI的技巧:const double PI=acos(-1.0);View Code #include<stdio.h>#include<math.h>const double PI=acos(-1.0);double a[10009];int n,m;double ss(double r){ return r*r*PI;}int much(double s)//当面积为S时可以把这些饼分成几个有效饼{ int i; int add=0; for(i=0; 阅读全文

posted @ 2011-08-29 21:51 huhuuu 阅读(409) 评论(0) 推荐(0) 编辑

摘要: 题目要求如何将月份分组就可以 使月份中的最大值最小二分查找上届:sum(a[i])下届:max(a[i])while(l<=r){ if(求的组别大于 题目要求) l=mid+1; else r=mid-1; ....统计(随时记录符合条件的月份中的最大值 的最小值)}注意 count<=m时就可以更新,count<m时一定可以分成m组View Code #include<stdio.h>int a[100009];int rmax;int zu(int max,int n)//可以分成几组{ int i; int add=1,t=0; rmax=0; ... 阅读全文

posted @ 2011-08-29 16:40 huhuuu 阅读(226) 评论(0) 推荐(0) 编辑

摘要: 哈密顿回路判断是个NP问题,只有爆搜才可以N=64,显然直接爆搜不行AAAA……其实可以缩成一个点ACACAC……缩成两个点(如单独存在A,C就需要两个AC)ACGACGACG……缩成三个点(如单独存在A,C,G就需要三个ACG)再DFS即可View Code #include<stdio.h>#include<string.h>int add[10];int ok=0;int all=0;int from;void fun(char ss[10]){ int i; int t=0; for(i=0;ss[i];i++) { if(ss[i]=='A') 阅读全文

posted @ 2011-08-29 14:22 huhuuu 阅读(2858) 评论(0) 推荐(1) 编辑

2011年8月17日

摘要: hash+置换群View Code #include<stdio.h>#include<string.h>int a[10009];int hash[100009];bool use[100009];int min1(int a,int b){ if(a>b)return b; else return a;}int main(){ int n; while(scanf("%d",&n)!=EOF) { int i,min=9999999,max=0; memset(hash,0,sizeof(hash)); memset(use,0,s 阅读全文

posted @ 2011-08-17 10:18 huhuuu 阅读(387) 评论(0) 推荐(0) 编辑

2011年8月16日

摘要: 统计正方形个数 set做结构体要加:friend bool operator<(data a,data b) { if(a.x==b.x) return a.y>b.y; else return a.x>b.x; }枚举正方形的两个点 知道下面两个点寻找set中这两个点是否存在View Code #include<stdio.h>#include<string.h>#include<iostream>#include<set>using namespace std;struct data{ int x,y; friend boo 阅读全文

posted @ 2011-08-16 20:43 huhuuu 阅读(341) 评论(0) 推荐(0) 编辑

2011年8月8日

摘要: 死亡游戏,问一把左轮枪,左轮有N个空间,其中用k发子弹,有p个问题,问抢第a[i]个空间有木有子弹,小明为了使自己被秒的概率最小,如何摆放子弹(游戏会一直继续知道有人挂掉),答案要按字典序显示。。。 分类思想吧 7 0 7(为了方便1-7顺序) 。。。。。。。 7 1 7 。。。。。。X 7 2 7 。。。。。XX 7 3 7 。。。X。XX 7 4 7 。X。X。XX ... 8 0 8 不写了,把情况都列一下,总结规律View Code #include<stdio.h>int main(){ __int64 n,k,p; int i; scanf("%I64d%I6 阅读全文

posted @ 2011-08-08 16:57 huhuuu 阅读(235) 评论(0) 推荐(0) 编辑

上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 50 下一页