雕刻时光

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

2011年11月18日

摘要: http://poj.org/problem?id=3045贪心,按Wi+Si排列对于最后一个位置,risk=W总-Wn-Sn,使得risk最小的是最大的(Wi+Si)。View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct data{ int w,p; long long all;}node[50009];int cmp(data a,data b){ return (a.p+a.w) 阅读全文

posted @ 2011-11-18 21:09 huhuuu 阅读(173) 评论(0) 推荐(0) 编辑

2011年11月17日

摘要: http://www.zybbs.org/JudgeOnline/problem.php?id=1653STL组合数枚举下算总和的话其实就是杨辉三角View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[19];int b[19];int s[19][19];void fun(){ int i,j; memset(s,0,sizeof(s)); for(i=1;i<=10;i++) 阅读全文

posted @ 2011-11-17 21:28 huhuuu 阅读(316) 评论(0) 推荐(0) 编辑

2011年11月9日

摘要: 如123321 保留4个数字最小结果为1221线性算法:先在1-3个之间找,记录ri再到ri+1-4之间找。。。View Code #include<stdio.h>#include<string.h>char ss[60009];int main(){ while(scanf("%s",ss)!=EOF) { int i,len,end,ri=0; len=strlen(ss); int add,app=0; //scanf("%d",&add); add=6;... 阅读全文

posted @ 2011-11-09 21:13 huhuuu 阅读(394) 评论(0) 推荐(0) 编辑

摘要: 对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数。例如,整数1,2,4,6等都是反质数。现在给定一个数N,你能求出不超过N的最大的反质数么?先百度知道反素数性质性质一:一个反素数的质因子必然是从2开始连续的质数.因为最多只需要10个素数构造:2,3,5,7,11,13,17,19,23,29性质二:p=2^t1*3^t2*5^t3*7^t4.....必然t1>=t2>=t3>=....搜索。。。View Code #include<stdio.h>#i 阅读全文

posted @ 2011-11-09 16:07 huhuuu 阅读(369) 评论(0) 推荐(0) 编辑

2011年11月6日

摘要: 如输入33 5 4 6输出 33 4 53 5 6思路:最长子序列有几个通过n*log(n)算出来再用dfs+路径记录输出所有的值View Code #include<stdio.h>#include<string.h>#include<stack>#include<iostream>using namespace std;#define MAXN 109int ok=0;int n,a[MAXN],s[MAXN];//ÐòÁдæÔÚsÀïint 阅读全文

posted @ 2011-11-06 21:09 huhuuu 阅读(410) 评论(0) 推荐(0) 编辑

2011年11月3日

摘要: n 为环的大小 ,m 为每隔m,kill一个人View Code #include<stdio.h>#include<string.h>int a[109];int main(){ int i,j,n,count,m; while(scanf("%d %d",&n,&m)!=EOF) { memset(a,0,sizeof(a)); int add=0; i=0,count=1; while(add<n-1) { while(a[i]!=0) ... 阅读全文

posted @ 2011-11-03 21:52 huhuuu 阅读(163) 评论(0) 推荐(0) 编辑

2011年10月31日

摘要: escription给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。Input第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度Output所构成不重复矩形的个数思路:由于是一个圆,所以要用到类似循环的数组,将原来的数组增加n-1如n=4延长到1 2 3 4 1 2 3即可达到循环效果枚举即可View Code #include<stdio.h>int a[99];int main(){ int n,i,j; while(scanf("%d& 阅读全文

posted @ 2011-10-31 22:37 huhuuu 阅读(314) 评论(0) 推荐(1) 编辑

2011年10月30日

摘要: View Code #include<stdio.h>#include<math.h>long long mon(long long n,long long p,long long m){ n=n%m; long long all=1; while(p>0) { if(p&1==1) { all=(all*n)%m; } n=(n*n)%m; p>>=1; } return all;}int main(){ long long n,m; while(sca... 阅读全文

posted @ 2011-10-30 16:32 huhuuu 阅读(303) 评论(0) 推荐(0) 编辑

摘要: dp[x][y][y]=nx,y,z分别代笔三座塔德高度,n是到达该高度最多需要//ta,tb,tc为该塔最高可达高度,可以降低时间复杂度View Code #include<stdio.h>#include<string.h>int dp[121][121][121];int main(){ int n; while(scanf("%d",&n)!=EOF) { int i,x,y,z; int a=0,b=0,c=0,ta=0,tb=0,tc=0;//ta,tb,tc为该塔最高可达高度,可以降低时间复杂度 memset(dp,-1... 阅读全文

posted @ 2011-10-30 15:15 huhuuu 阅读(257) 评论(0) 推荐(0) 编辑

2011年10月29日

摘要: 编程解决如下数学问题:有12升水,怎样利用一个8升和一个5升的容器将水分为两个6升?要求以如下格式打印出分水步骤。(20分) a12 b8 c5 12 0 0 * * * ( “*”表示当前状态下每个容器的盛水量) ...... 0 6 6View Code #include<iostream>#include<queue>#include<stack>using namespace std;struct data1{ int x,y,z; int use;}hash[19][19][19];int w,ll,rr;struct data{ int a,b, 阅读全文

posted @ 2011-10-29 22:33 huhuuu 阅读(1020) 评论(0) 推荐(0) 编辑

上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 50 下一页