- 博客(19)
- 收藏
- 关注
原创 【牛客网】最小操作数
emmm……好久没做题,卡在这个入门级动态规划上了。题目表述给定一个原串和目标串,能对源串进行如下操作: 1.在给定位置插入一个字符; 2.替换任意字符; 3.删除任意字符 要求完成一下函数,返回最少的操作数,使得源串进行这些操作后等于目标串。源串和目标串长度都小于2000。首先这种题肯定是要分情况讨论的,设原串为,目标串为B,那么有如下两种情况:原串的第一个字母和目标...
2018-07-18 12:46:32
1649
原创 HDU1022
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022给你两串数 输出让第一串变成第二串的进出栈过程,如果能,输出yes,并输出进出栈的过程,如果不能,输出no。在每种情况最后输出FINISH栈的基本运用吧!用一个vector数组记录进出栈情况。#include <iostream>#include <stack>#include<vector>
2016-09-30 19:28:03
309
原创 HUD1017
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1017没什么好说的,直接循环遍历,记录可行情况 要注意的是最后一种情况输出时没有换行!#include<iostream>int deal(int n,int m){ int count=0; long long res; for(int a=1;a<n;a++) {
2016-09-30 19:13:25
222
原创 HDU1425
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1425排序一下输出前n个,最后一个数后面有空格会报错!#include<iostream> #include<algorithm>#define Max 1000000+5using namespace std;int arr[Max];int main(){ int m,n;
2016-09-28 20:45:31
347
原创 HDU2035
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035又是一道快速幂。。。#include<iostream>int qp(int a,int b){ int t=a%1000,s=1; while(b) { if(b & 1) s=s*t%1000; t=t*t%100
2016-09-28 20:27:52
221
原创 HDU1170
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1170除法的输出居然没有考虑整除情况,结果连续wa了三次才发现#include<iostream>using namespace std;int main(){ int t,a,b; char c; scanf("%d",&t); while(t--) {
2016-09-28 19:48:55
453
原创 HDU1071
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1071题意就是给你三个点P1,P2,P3,三个点都在抛物线上,P1是抛物线的最高点,直线经过P2,P3。 让你求直线与抛物线相交部分的面积。刚开始做的时候有点懵逼,面积咋算?用积分,自己手算积分,然后把参数代进去因为三个点坐标给定,直线方程可以求得 抛物线方程可以由最高点坐标和左边或者右边一个点的坐标
2016-09-28 19:02:46
254
原创 HDU1020
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1020找到同一个字母连续出现的次数,然后按顺序输出次数和字母,如果次数为1数字就不用输出#include<iostream>#include<cstring>int main(){ char str[10001]; int n; scanf("%d",&n); whil
2016-09-28 16:58:39
215
原创 HDU1108
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1108求两个数的最小公倍数#include<iostream>int gcd(int a,int b){ if(a<b) { int flag; flag=a;a=b;b=flag; } if(b==0) return a; ret
2016-09-28 13:22:41
280
原创 HDU1049
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1049蜗牛爬井问题,考虑最后可以一次性爬出去,花时间1分钟,剩下的每两分钟走过的距离是上爬的距离减下滑的距离,然后计算总时间#include<iostream> int main(){ int a,b,c; while(scanf("%d%d%d",&a,&b,&c),a,b,c)
2016-09-28 13:17:00
244
原创 HDU1019
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1019题目意思就是让求m个数的最小公倍数,最近爱上做水题了QAQ根据定义,lcm(a,b)=a*b/gcd(a,b),然后就一对一对求吧!上代码#include<iostream>using namespace std;int gcd(int a,int b){ if(a<b) {
2016-09-28 12:57:41
224
原创 HDU 1061
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061一上来先无脑每次乘完用10取余,提交了一遍,果然超时。然后分析发现各个数的周期是1、2、4 然后乱搞了一下居然过了!!! 不过把1024换成更小就会wa#include<iostream>using namespace std;int main(){ long long n,m,i
2016-09-27 23:41:57
370
原创 HDU1021
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1021又是一道水题找数列中能被三整除的,找规律发现第2、6、10、...、2+4n 个数可以被3整除。那么读入后直接判断即可!#includeusing namespace std;int main(){ int n; while(cin>>n) { if(
2016-09-27 19:46:43
183
原创 HDU 1009
link HDU1009题目大意 老鼠有M磅catfood,有M个房间。老鼠用catfood交换javabeans,交换的方式有两种,一种是用f[i]交换j[i],还有一种是等比交换。 要求换取最多的javabean,那么优先选取j[i]/f[i]比值大的,不能取完的部分等比交换。 开一个结构体,存储f,j,rate,把rate按降序排序一下即可。#include<iostream>#inc
2016-09-26 23:38:39
167
原创 HDU 1008
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1008典型水题,第一次居然wa了,没考虑停在同一层也要算等待时间题目大意电梯上升一层要6秒,下降一层4秒,在那一层要停5秒,计算总时间#include<iostream> using namespace std;int main(){ int n; int up=6,down=4,
2016-09-26 22:27:20
175
原创 HDU 1005
Problem descriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).InputThe input consis
2016-09-23 20:13:26
475
原创 HUD 1004
Problem DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most popular problem. When the contest is o
2016-09-23 18:05:46
303
原创 Max Sum
Problem descriptionGiven a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14
2016-09-23 00:10:39
251
原创 免费馅饼
problem description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏
2016-09-22 19:56:08
168
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人