自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

原创 POJ -- 1186 Stripies

给出n个Stripies生物的重量,两个两个生物相撞成一个生物,相应的体积也会发生变化,新的生物重量为2*sqrt(m1*m2).注意这个公式,只有两个重量m1,m2越相近,得到的新的重量才越小,所以只需要把给出的所有重量从大到小排序即可,再逐个求出。 代码实现如下: #include #include #include using namespace std; const int Max=1

2014-11-29 22:00:39 348

原创 HDU -- 1114 Piggy-Bank

这是一道完全背包题,也是我的做的第一个完全背包题。这道题描述的是 给出一个小猪储钱罐的空的重量,被钱币装满的重量,给出几种不同硬币的价值 重量,要用这些硬币恰好装满小猪储钱罐,每中硬币可以使用多个,求出恰好装满储钱罐的钱币的最小价值如果不能恰好装满就输出这是不肯能的,否则输出钱币的价值。很容易让人想到用一个二维数组dp[i][j]来描述用i种钱币恰好装满重量为j的储钱罐的最小价值。要注意是恰好装满

2014-11-29 21:47:02 364

原创 HDU--2602 Bone Collector

给出骨头的个数,及每个骨头的价值,体积,背包的容量,求该该背包容量下能装的最大价值; 这是一道传统的01背包题,用dp[i][j]表示把前i个物品装到容积为j的背包中的最大容量,那么对第i个物品有两个决策,装或不装。此时的状态转移方程为dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i]]+w[i]) 代码实现如下: #include #include const i

2014-11-27 19:53:08 298

原创 HDU--1176 免费馅饼

给出一组时间,及在每个时间饼掉落的位置,同一秒可以在同一点掉多个饼,初始位置为5这个点,每秒钟只能移动一个格,则第一秒钟只能接到4 5 6 这三个饼的数量,求最后能接到的最大饼数量。 可以a[i][j]表示在第i秒掉落在第j个位置上的饼的数量;每次读取一个时间,地点,该位置的饼数量就加1; 用d[i][j]表示在第i秒的第j个位置能接到的最大饼数量。 这道题相当于数塔那道题。因为每秒只能走一

2014-11-27 19:41:21 264

原创 命运

只能向右或者向下走,向下一次只能走一格。但是如果向右走,则每次可以走一格或者走到该行的列数是当前所在列数倍数的格子,即:如果当前格子是(x,y),下一步可以是(x+1,y),(x,y+1)或者(x,y*k) 其中k>1; 命运大迷宫可以看成是一个两维的方格阵列,如下图所示:  从大魔王的那点出发,从第n行到第1行,从第m列到第1列依次遍历dp二维数组,相当于从右下角到左上角,dp[i]

2014-11-27 18:23:21 372

原创 POJ--1664 放苹果

Description 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input 第一行是测试数据的数目t(0 Output 对输入的每组数据M和N,用一行输出相应的K。 Sample Input 1 7 3 Sample Output 8

2014-11-24 22:06:55 402

原创 UVA--10827 Maximum sum on a torus

A grid that wraps both horizontally and vertically is called a torus. Given a torus where each cell contains an integer, determine the sub-rectangle with the largest sum. The sum of a sub-rectangle is

2014-11-23 09:22:04 331

原创 UVA--507 Jill Rides Again

Jill Rides Again  Jill likes to ride her bicycle, but since the pretty city of Greenhills where she lives has grown, Jill often uses the excellent public bus system for part of her jour

2014-11-22 14:55:38 312

原创 UVA--836 Largest Submatrix

Let A be an N×N matrix of zeros and ones. A submatrix S of A is any group of contiguous entries that forms a square or a rectangle. Write a program that determines the number of elements of the lar

2014-11-22 12:01:18 354

原创 uva_108 - Maximum Sum

Background A problem that is simple to solve in one dimension is often much more difficult to solve in more than one dimension. Consider satisfying a boolean expression in conjunctive normal form i

2014-11-20 19:59:40 338

原创 Maximum Subarray模板

初步学习 正确性还有待考证 1.周

2014-11-20 01:22:57 309

原创 HDU -- 2519 新生晚会

Problem Description 开学了,杭电又迎来了好多新生。ACMer想为新生准备一个节目。来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法?   Input 数据的第一行包括一个正整数T,接下来有T组数据,每组数据占一行。 每组数据包含两个整数N(来报名的人数,1   Output 每组数据输出一个整数,每个输出占

2014-11-18 22:41:56 483

原创 HDU--2115 I Love This Game

Problem Description Do you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , sho

2014-11-18 22:38:14 320

原创 ZOJ -- 2833 Friendship

Now you've grown up, it's time to make friends. The friends you make in university are the friends you make for life. You will be proud if you have many friends. Input There are multiple test cases

2014-11-18 22:33:37 387

原创 UVA 12511 Virus

We have a log file, which is a sequence of recorded events. Naturally, the timestamps are strictly increasing. However, it is infected by a virus, so random records are inserted (but the order of ori

2014-11-18 07:05:30 432

原创 HDU--1087 Super Jumping! Jumping! Jumping!

Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.

2014-11-17 11:45:38 303

原创 UVA—10131 Is Bigger Smarter?

The Problem Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as p

2014-11-16 20:32:48 331

原创 Testing the CATCHER

最长非上升子序列 贪心: #include const int Max=10000; int str[Max+10]; int stack[Max+10]; int bsearch(int num,int top){ int low=1,high=top; while(low<=high){ int mid=(low+high)/2; if(nu

2014-11-16 18:48:19 384

原创 HDU--Primes Problem

Problem Description Given a number n, please count how many tuple(p1, p2, p3) satisfied that p1 Input Multiple test cases(less than 100), for each test case, the only line indicates the positive

2014-11-16 12:49:43 401

原创 UVA--531 Compromise

In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except

2014-11-12 22:25:49 277

原创 LCS常用模板总结

1.求最长公共子串长度: (1)

2014-11-12 22:16:10 487

原创 UVA--10252 Common Permutation

Given two strings of lowercase letters, a and b, print the longest string x of lowercase letters such that there is a permutation of x that is a subsequence of a and there is a permutation of x that

2014-11-11 14:07:11 497

原创 输出最长公共子序列字母表顺序

#include #include #include using namespace std; const int Max=1000; char str1[Max+10]; char str2[Max+10]; char str[Max+10]; int p[Max+10][Max+10]; int maxlen[Max+10][Max+10]; int cnt=0; void print(int

2014-11-11 02:05:06 476

转载 gets与scanf

gets函数的读取规则: 1.只要gets遇到换行符,即便它是输入的第一个字符,gets也会停止读入并返回。如果输入的第一个字符就是换行符,则字符串将被置为空串。 2.由于gets函数读入再丢弃换行符,换行符将不会存储在字符串中。 gets的读取规则与getline是一样的。 gets函数的返回值: 1.正常读入(未遇到文件结尾)(注意,读入空串也是正常读入),则返回

2014-11-10 19:11:02 483

转载 最长公共子序列问题LCS

问题描述 一个给定序列的子序列是在该序列中删去若干元素后得到的序列。确切地说,若给定序列X=x1, x2,…, xm>,则另一序列Z=z1, z2,…, zk>是X的子序列是指存在一个严格递增的下标序列 i1, i2,…, ik>,使得对于所有j=1,2,…,k有 例如,序列Z=是序列X=的子序列,相应的递增下标序列为。 给定两个序列X和Y,当另一序列Z既是X的子序列又是Y的

2014-11-10 17:33:28 1720

原创 UVA--10066 The Twin Towers

#include #include const int Max=100; int str1[Max+10]; int str2[Max+10]; int maxlen[Max+10][Max+10]; int main(){ int cnt=0; int l1,l2; while(scanf("%d%d",&l1,&l2)==2){ if(l1==0&&l2

2014-11-10 17:24:46 314

原创 uva-111 G - History Grading

#include #include int str1[25]; int str2[25]; int maxlen[25][25]; int main(){ int n,t; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&t); str1[t-1]=i+1; } while(

2014-11-10 17:11:59 345

原创 hdu--2084 数塔

#include int a[105][105]; int sum[105]; int main(){ int c; while(scanf("%d",&c)==1){ for(int k=0;k<c;k++){ int n; scanf("%d",&n); for(int i=0;i<n;i+

2014-11-06 01:53:08 331

原创 hdu--2041 超级楼梯

#include int cnt[50]; int main(){ int n; while(scanf("%d",&n)==1){ for(int k=0;k<n;k++){ int m; scanf("%d",&m); cnt[0]=1; cnt[1]=1;

2014-11-06 01:15:22 344

原创 As Easy As A+B--最基本sor排序样例

#include #include using namespace std; const int Max=1000; int a[Max+10]; int main(){ int t; while(scanf("%d",&t)==1){ for(int k=0;k<t;k++){ int n; scanf("%d",&

2014-11-04 22:28:21 449

原创 hdu--2020 绝对值排序

#include #include #include using namespace std; const int Max=100; int a[Max+10]; int cmp(int a1,int a2){ if(abs(a1)>abs(a2)) return 1; else return 0; } int main(){ int n; whil

2014-11-04 22:25:20 447

原创 hdu--1862 EXCEL排序

#include #include #include using namespace std; const int Max=100000; struct stu{ int no; char name[15]; int score; }a[Max+20]; int cmp1(stu a,stu b){ return a.no<b.no; } int cmp2(stu a

2014-11-04 22:24:26 429

原创 最长公共子序列

#include #include const int Max=1000; char str1[Max],str2[Max]; int maxlen[Max][Max]; int main(){ while(scanf("%s%s",&str1,&str2)==2){ int len1=strlen(str1); int len2=strlen(str2);

2014-11-01 11:02:40 313

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除