LeeBlog

导航

上一页 1 2 3 4 5 6 7 8 ··· 19 下一页

2011年5月13日 #

HDU 2036 改革春风吹满地

摘要: 一个多边形公式s = ( x1*y2-x2*y1 ) + ( x2*y3 - x3*y2 )……( xn-1*yn - xn*yn-1 ) + ( xn*y0 - x0*yn );一个公式就OK了#include<stdio.h>int n;double x[105],y[105],sum ;int main( ){ while( scanf( "%d",&n ),n ) { sum = 0; for( int i = 0 ; i < n; ++i ) { scanf( "%lf%lf",&x[i],&y[i] 阅读全文

posted @ 2011-05-13 10:04 LeeBlog 阅读(250) 评论(0) 推荐(0) 编辑

HDU 2955 Robberies

摘要: 这题开始我拿了,不知怎么下手,但幸好这题是在背包这里,提示了我,肯定能用背包解,但显然概率不能作为一维数组的下标,所以只能找价值来当一维数组下标,而要不失败,即全部成功,求全部成功的概率就行了。其实仔细想想0-1背包的二维中两个下标是对称的。还有0要初始化为1,因为如果神马都不抢成功率为1#include<stdio.h>#include<string.h>double dp[10005],W,w[10005];int n,v[10005],ma;double max( double a,double b ){ return a > b ? a : b;}void 阅读全文

posted @ 2011-05-13 09:08 LeeBlog 阅读(189) 评论(0) 推荐(0) 编辑

HDU 1008 Elevator

摘要: #include<stdio.h>int main( ){ int n,sum,a,b; while( scanf( "%d",&n ),n ) { sum = 0; a = 0; for( int i = 0; i < n; ++i ) { scanf( "%d",&b ); sum += 5; if( b > a ) sum += ( b - a ) * 6; if( b < a ) sum += ( a - b ) * 4; a = b; } printf( "%d\n",sum ) 阅读全文

posted @ 2011-05-13 00:36 LeeBlog 阅读(231) 评论(0) 推荐(0) 编辑

2011年5月12日 #

HDU 1085 Holding Bin-Laden Captive! 母函数||背包||递推

摘要: 水题 。。 直接把所有可能枚举。。 最后找出没有可能的,即系数为0 的最小数#include<stdio.h>#include<string.h>int s[4] = {0,1,2,5},m1[100000],m2[100000],num[4],max;void gf( ){ memset( m1,0,sizeof( m1 ) ); memset( m2,0,sizeof( m1 ) ); for( int i = 0; i <= num[1]; ++i ) m1[i] = 1; for( int i = 2; i <= 3; ++i ) { for( in 阅读全文

posted @ 2011-05-12 10:37 LeeBlog 阅读(172) 评论(0) 推荐(0) 编辑

HDU 1398 Square Coins

摘要: 好吧。。 这题是母函数的同一类型题。。。。。暴力也可以过#include<stdio.h>int sq[18],m1[305],m2[305];void chart( ){ for( int i = 0; i < 305; ++i ) m1[i] = m2[i] = 0; for( int i = 0; i < 18; ++i ) sq[i] = i * i; m1[ 0 ] = 1; for( int i = 1; i <= 17; ++i ) { for( int j = 0; j <= 300; ++j ) for( int k = 0; ( j + 阅读全文

posted @ 2011-05-12 08:59 LeeBlog 阅读(153) 评论(0) 推荐(0) 编辑

HDU 2082 找单词

摘要: 这题是母函数的一基本题。跟2079差不多http://www.cnblogs.com/Lvsi/archive/2011/05/11/2043707.html不过这里相邻括号递增的幂是依次递增的,不过这次我又犯了一个错误,很严重的,在写k的时候竟然写成k*i<= map[i]oh~ so bad ... 以后谨记#include<stdio.h>int map[28],m1[100],m2[100],n;void gf( ){ m1[0] = 1; for( int i = 1; i <= 26; ++i ) { for( int j = 0; j <= 50; 阅读全文

posted @ 2011-05-12 08:36 LeeBlog 阅读(217) 评论(0) 推荐(0) 编辑

2011年5月11日 #

HDU 2079 选课时间(题目已修改,注意读题) 母函数 || 多重背包

摘要: 今天做这题才知道原来母函数的原型不是从第二个括号开始,那不过是优化而已,除了1^n,2^n那种类型可以从2开始外其他都要从1开始。好了,上代码吧。#include<stdio.h>int n,k,m1[450],m2[450],t,a,b;int num[15],sc[15];void gf( ){ for( int i = 0; i <= num[1];i++ ) m1[i*sc[1]] = 1; for( int i = 2; i <= k;++i ) { for( int j = 0; j <= n; ++j ) for( int l = 0; l < 阅读全文

posted @ 2011-05-11 22:00 LeeBlog 阅读(612) 评论(1) 推荐(0) 编辑

HDU 2564 词组缩写

摘要: 这个要注意把缩写的最后一个字符串置为0#include<stdio.h>#include<string.h>#include<ctype.h>char str[1000],s[1000];int main( ){ int t; scanf( "%d%*c",&t ); while( t-- ) { gets( str ); int i = 0,c = 0; while( str[i] ) { if( !isalpha( str[i] ) ) { ++i; continue; } if( str[i] > 'Z' 阅读全文

posted @ 2011-05-11 17:40 LeeBlog 阅读(313) 评论(0) 推荐(0) 编辑

HDU 1005 Let the Balloon Rise

摘要: 水题 。。 就是从给出的字符串中找出出现次数最频繁的那一个。。。直接暴力。。 给没个字符串一个编号。。#include<stdio.h>#include<string.h>int n,c,des[1005];char ch[1005][20];int search( char str[] ){ for( int i = 0; i < c; ++i ) if( !strcmp( ch[i],str ) ) return i; return c++;}int main( ){ while( scanf( "%d",&n ),n ) { c 阅读全文

posted @ 2011-05-11 16:54 LeeBlog 阅读(217) 评论(0) 推荐(0) 编辑

HDU 2156 分数矩阵

摘要: 找关系。。。。1/1 1/2 1/31/2 1/1 1/21/3 1/2 1/1出了1以外有这样的规律1/2有(3-1)*2个1/2有 ( 3 - 2 ) * 2个那么可以猜想结果为sum = n * 1 / 1 + ( n - 1 ) * 2 * 1 / 2 + ( n - 2 ) *2*1/3+.......+(n-i+1)*2*1/i;#include<stdio.h>#include<stdlib.h>#include<math.h>int n;double cal( ){ double sum = 0; sum = n; for( int i = 阅读全文

posted @ 2011-05-11 11:44 LeeBlog 阅读(272) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 19 下一页