上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 42 下一页
摘要: floyd题意:给定一些money以及之间的转化,询问最后能不能让某种money升值View Code 1 #include<stdio.h> 2 #include<map> 3 #include<string> 4 #include<iostream> 5 using namespace std; 6 const int maxn = 105; 7 map<string,int>mp; 8 double mat[ maxn ][ maxn ]; 9 double fmax( double a ,double b ){10 retur 阅读全文
posted @ 2012-12-22 23:18 xxx0624 阅读(445) 评论(0) 推荐(0) 编辑
摘要: 方法一:简单易懂View Code 1 const int maxn = 10005 ; 2 int prime[ maxn ],shu[ maxn ]; 3 void get_prime(){ 4 for( int i=1;i<maxn;i+=2 ) shu[ i ]=1; 5 for( int i=0;i<maxn;i+=2 ) shu[ i ]=0; 6 shu[ 1 ]=0,shu[ 2 ]=1; 7 for( int i=3;i<maxn;i+=2 ){ 8 if( shu[ i ]==1 ){ 9 int t... 阅读全文
posted @ 2012-12-21 23:56 xxx0624 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 简单DP题意:给定一些block的xyz坐标。求使得某些block叠起来得到的最大高度。dp[ i ].ans=max( dp[ 0....i-1 ].ans );( 还必须满足block[ i ].x,block[ i ].y 都小于dp[ k ].x,dp[ k ].y );View Code 1 /* 2 dp 3 */ 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<algorithm> 8 #include<iostream> 阅读全文
posted @ 2012-12-20 18:10 xxx0624 阅读(1022) 评论(0) 推荐(0) 编辑
摘要: 题意:给定几个坐标,在这些坐标上 t 时刻会有陨石雨。怎样在最短的时间内找到一个安全的地方。方法:预处理,把每个坐标有陨石的地方预处理出来,这样在bfs的时候会很简单,比如不用考虑待在原点不懂,或者往回走之类的View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<queue> 5 #include<algorithm> 6 using namespace std; 7 const int maxn = 405; 8 const 阅读全文
posted @ 2012-12-19 19:58 xxx0624 阅读(1615) 评论(0) 推荐(0) 编辑
摘要: 附代码View Code 1 /* 2 无向图的联通分量 3 dfs 4 */ 5 #include<stdio.h> 6 #include<string.h> 7 const int maxn =30 ; 8 int map[ maxn ][ maxn ]; 9 int vis[ maxn ];10 int max;11 void dfs( int now ){12 //vis[ now ]=1;13 for( int i=1;i<=max;i++ ){14 if( map[ now ][ i ]==0||map[ i ][ now ]==0 ) conti.. 阅读全文
posted @ 2012-12-17 00:18 xxx0624 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 字符串的翻转注意一些特殊的情况即可View Code 1 /* 2 字符翻转 3 注意这种情况:_ _ ab_ _ _cc_ _ 4 "_"都是要输出的 5 6 */ 7 #include<stdio.h> 8 #include<string.h> 9 const int maxn = 1105;10 char s[ maxn ];11 int main(){12 int n;13 scanf("%d",&n);14 getchar();15 while( n-- ){16 int len;17 gets( s );18 阅读全文
posted @ 2012-12-16 22:52 xxx0624 阅读(552) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2012-12-14 22:41 xxx0624 阅读(166) 评论(0) 推荐(0) 编辑
摘要: n^n=10^( n*log10( n ) );View Code 1 /* 2 n^n 的最高位 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 const int maxn 阅读全文
posted @ 2012-12-14 20:07 xxx0624 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 规律题View Code 1 /* 2 n^n 个位 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 const int maxn = 1005;14 const int in 阅读全文
posted @ 2012-12-14 20:06 xxx0624 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 完全:题意:给定E,F,分别表示空的存钱罐的重量和装了钱之后的重量。给定n种money的价值和重量dp[ i ][ j ]:表示从前 i 种money中选出某些,使得重量至少为 j 得到的最大价值。View Code 1 /* 2 完全背包 变形 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include&l 阅读全文
posted @ 2012-12-14 19:05 xxx0624 阅读(604) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 42 下一页