自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

fanesemyk的博客

当断不断,反受其乱!

  • 博客(25)
  • 收藏
  • 关注

原创 hdu 2546 饭卡

Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Inpu

2016-07-30 20:11:51 193

原创 hdu 1025 Constructing Roads In JGShining's Kingdom

Problem DescriptionJGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these cities are rich in resource (we call them rich

2016-07-30 19:56:29 330

转载 背包九讲中的公式

void ZeroOnePack(int value,int cost){ for(int j=m;j>=cost;j--) dp[j]=max(dp[j],dp[j-cost]+value);}void CompletePack(int value,int cost){ for(int j=cost;j<=m;j++) dp[j]=max(

2016-07-30 16:26:29 393

原创 Codeforces 614C Peter and Snow Blower

C. Peter and Snow Blowertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeter got a new snow blower as a New Year pr

2016-07-22 11:05:32 576

原创 POJ 3669 Meteor Shower

Meteor ShowerTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 15092 Accepted: 3971DescriptionBessie hears that an extraordinary meteor shower is coming

2016-07-21 20:20:00 292

原创 Codeforces Problem 614B Gena's Code

B. Gena's Codetime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's the year 4527 and the tanks game that we all kn

2016-07-21 16:57:05 358

原创 codeforces 699D Fix a Tree

D. Fix a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is an undirected connected graph without cycles.

2016-07-20 10:47:07 442

原创 codeforces 699B One Bomb

DescriptionYou are given a description of a depot. It is a rectangular checkered field ofn × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").You have on

2016-07-20 10:15:06 255

原创 Open Judge 1664 Placing apples

DescriptionWe are going to place M same apples into N same plates.There could be some empty plates.How many methods do we have?When we have 7 applesand 3 plates, the methods, (1, 5, 1) and (

2016-07-19 20:20:36 499

原创 Open Judge 2811 熄灯问题

有一个由按钮组成的矩阵,其中每行有6个按钮,共5行。每个按钮的位置上有一盏灯。当按下一个按钮后,该按钮以及周围位置(上边、下边、左边、右边)的灯都会改变一次。即,如果灯原来是点亮的,就会被熄灭;如果灯原来是熄灭的,则会被点亮。在矩阵角上的按钮改变3盏灯的状态;在矩阵边上的按钮改变4盏灯的状态;其他的按钮改变5盏灯的状态。在上图中,左边矩阵中用X标记的按钮表示被按下,右边的矩阵表示灯状态的改

2016-07-19 20:12:01 1248

原创 C++ string和stringstream的简单运用

string和stringstream用的好了可以让程序更加简单,同时程序的运行耗时也会更加多。下面来一个示范:#include#include#include#include#includeusing namespace std;int main(){ //freopen("in.txt","r",stdin); string line; while(g

2016-07-17 10:53:55 470

原创 hdu 5676ztr loves lucky numbers

排列组合,打表法。今天学了一个新的函数:next_permutation(a,a+n).具体用法可以百度,大概就是把a全排列,然后返回1(排列成功)或者0(已经是最大)#include#include#include#include#include#include#includeusing namespace std;char temp[20];char temp_b

2016-07-15 15:17:01 377

原创 poj 1328 Radar Installation

贪心的典型例题,就是给你n个区间,问最少取多少个点,才能使每个区间内都有点。思路就是把右端点作为第一关键字排序,左端点作为第二关键字排序。然后从左向右遍历,如果有一段的左端点小于目前的右端点,就ans++,同时跳到这一段的右端点。这道题要注意当输出-1的时候千万不要直接break,否则剩下的内容没有读入。#include#include#include#include#includ

2016-07-15 15:14:02 195

原创 WUST OJ 1373: 世界上只有10种人

这道题有点卡,主要是在把数转换成二进制的过程,是很好的递归题目。#include<stdio.h>#include<iso646.h>#include<limits.h>#include<algorithm>#include<math.h>using namespace std;int a[20],k=0;void zhuanhuan(int n){ if((n!=0)and(n!=1))

2016-07-15 15:03:06 379

原创 HDU 5641 King's Phone

Problem DescriptionCA loves to play with sticks. One day he receives four pieces of sticks, he wants to know these sticks can spell a quadrilateral. (What is quadrilateral? Click here: https://en.wik

2016-07-15 14:55:16 252

原创 命令行中使用gcc编译器和gdb调试

先在命令行中输入g++看看有没有反应,没有就百度一下如何添加。常见编译选项gcc test.c//编译为a.exe文件gcc test.c -o test //编译为test.exe文件gcc test.c -o test -Wall -ansi -pedantic //编译并检查错误(一般wall即可)gcc test.c -o test -lm //链接数学库(C++不用)还有一些编译选项

2016-07-14 20:54:53 3958

原创 Windows下批处理对拍程序

@echo off:againdatamaking>input                                         ;生成随机输入a<input>output.ab<input>output.bfc output.a output.b                                     ;比较文件if not errorlevel 1 go

2016-07-14 20:30:24 518

原创 算法竞赛入门经典第二版第三章习题

写这个的原因是看到一位大神的习题答案总结,于是自己心血来潮也想写一个这个,目的主要是督促自己刷题吧,毕竟自己太弱了。习题3-1 得分 UVa 1585大致就是设置一个变量记录到当前为止的连续的O的数量,碰到X就变0,水题。#include<stdio.h>#include<ctype.h>#include<string.h>char s[90];int main(void){ in

2016-07-14 10:56:43 2097

原创 最基础的——windows下命令行操作(本博客将不断更新)

如何打开命令行(win10为例):1.快捷键ctrl+s打开搜索2.搜索“运行”关键词3.在“运行”中打入cmd,回车4.这就是命令行啦5.输入文件地址(如F:/)最基础的 echo(标准写入写出操作)echo 50|abc翻译:把50作为写入,运行abc在vs2015开发人员命令提示中编译源代码cl /EHsc prog.cpp回到上一层路径cd..进入目录下某一文件cd name文件重定向输入输

2016-07-13 21:00:49 2785

原创 poj1700 Crossing River

http://www.cnblogs.com/yueshuqiao/archive/2011/07/22/2113698.html这篇博客讲的很好,推荐一下。 自己想了一个小时都不会,太菜了。 核心思路是让重的先走。#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace s

2016-07-13 19:40:07 244

原创 POJ 3061  Subsequence

这道题有两种做法,一种是比较简单的暴力二分,复杂度为O(nlogn),另一种则是我采取的尺取法。 所谓尺取法,就是像尺子一样一点一点往右移。事实上,对于这道题,我更愿意称它为蚯蚓法:像蚯蚓一样一点点向前移动。 说一下原理:核心是两个指针,移来移去。我们的目的是:使得j指向以i开头的,最短的一个元素(即I到j-1不行)。这样,当i变成I+1时,可以保证I+1到j-1肯定不行。则j就不变或者自增,直

2016-07-13 19:36:16 248

原创 hdu 2091 空心三角形

hdu 2091 空心三角形简单的模拟。注意题目中要求行末不能有多余的空格。 我犯了两个错误,一个是continue和break搞混了;第二个是以前犯过的错误,但没有重视,就是读入字符的时候,一定要特别小心空格符和换行符。下面贴代码#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using nam

2016-07-11 14:51:19 211

原创 利用尾递归实现进制转换

利用尾递归实现进制转换以二进制为例void to_binary(unsigned int n){ int r; r=n%2; if(n>=2) to_binary(n/2); putchar('0'+r); return ;}原理为除二取余法

2016-07-11 14:46:00 253

原创 hdu 1019 Least Common Multiple

WA了好几发,原因是越界。原来的处理方法是用long long避免越界,思路是对的,但在处理过程中出现了小差错。例子:int a,b;long long chengji;chengji=a*b;这种写法是错的,因为在右边两个int相乘时就越界了。 正确写法是int a,b;long long chengji;chengji=(long long)a*(long long)b;或者也可以C语

2016-07-11 14:41:34 249

原创 集训计划

集训计划科目二考过减肥15斤扇贝英语GRE单词数据结构公开课C++自学一部分图论 动态规划深入学习紫书刷完

2016-07-10 20:12:27 213

空空如也

空空如也

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

TA关注的人

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