自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Qt4和Qt5通用做法整理

1.在pro文件中,最后加上 printsupport。2.不要写#include<QtGui/QtGui>Qt4里可以,Qt5里应该不行,我在linux环境用Qt5运行会报错。解决方法:把它拆分一下就行。3.不要写QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));Qt4里可以,Qt5里不行。解决方法:QTextCodec *pcode = QTextCodec::codecForName ("G

2022-05-25 14:11:40 1396

原创 报错:Could not connect to any X display

Linux通过终端命令无法启动图形应用,报错“Could not connect to any X display.”解决方法:以当前用户身份重新打开一个终端,输入“xhost +”命令。

2022-05-24 08:47:00 7240

原创 解决QtCreator中文乱码问题

示例程序:#include<QtGui/QApplication>#include<QtGui/QWidget>#include<QtGui/QLabel>#include<QtCore/QTextCodec>int main(int argc, char *argv[]){ QApplication app(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForNam

2022-05-23 13:41:59 3614 2

原创 17.16. 按摩师

一个有名的按摩师会收到源源不断的预约请求,每个预约都可以选择接或不接。在每次预约服务之间要有休息时间,因此她不能接受相邻的预约。给定一个预约请求序列,替按摩师找到最优的预约集合(总预约时间最长),返回总的分钟数。示例 1:输入: [1,2,3,1]输出: 4解释: 选择 1 号预约和 3 号预约,总时长 = 1 + 3 = 4。示例 2:输入: [2,7,9,3,1]输出: 12解释: 选择 1 号预约、 3 号预约和 5 号预约,总时长 = 2 + 9 + 1 = 12。示例 3:输入

2020-11-02 14:55:32 231

原创 4. 寻找两个正序数组的中位数

给定两个大小为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的中位数。进阶:你能设计一个时间复杂度为 O(log (m+n)) 的算法解决此问题吗?来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/median-of-two-sorted-arrays示例 1:输入:nums1 = [1,3], nums2 = [2]输出:2.00000解释:合并数组 = [1,2,3] ,中位数 2示例 2

2020-10-27 15:26:48 134

原创 1552. 两球之间的磁力

在代号为 C-137 的地球上,Rick 发现如果他将两个球放在他新发明的篮子里,它们之间会形成特殊形式的磁力。Rick 有 n 个空的篮子,第 i 个篮子的位置在 position[i] ,Morty 想把 m 个球放到这些篮子里,使得任意两球间 最小磁力 最大。已知两个球如果分别位于 x 和 y ,那么它们之间的磁力为 |x - y| 。给你一个整数数组 position 和一个整数 m ,请你返回最大化的最小磁力。示例 1:输入:position = [1,2,3,4,7], m = 3输

2020-10-24 17:27:34 205

原创 867.转置矩阵

标题 867.转置矩阵重新开始刷题,好久没刷了,这次在leetcode上做题,做的第一个题是转置矩阵,才知道leetcode上的题不用写输入输出,还不太适应,这是我研究生生涯刷题的起点,希望我能坚持下去,第一道题虽然很简单,但感觉有些纪念意义,我把我简单写了带着输入输出的代码附上,提交的时候只用提交写的函数就行了。`#include<iostream>#include<vector>using namespace std;class Solution {public:

2020-10-20 16:40:11 114

原创 Flight hdu3499

这个题真的是做的我很难受,就是从开始sa的点搜一次,找到它到每个点的最短路dis1[I],再从终点sb搜一次,找到它到每个点的最短路dis[I],我建立了两个图,因为是单向的。搜完两次之后,再枚举所有的路,假设其中一个是从a到b,权值为w,则dis1[a]+dis2[b]+w/2就是始点sa到终点sb,把优惠券用到a到b这条路上的结果ans。循环m次,就能得到一个最小值。下面是AC代码:...

2018-11-25 16:55:54 191

原创 Til the Cows Come Home POJ - 2387

这个题可以不用堆优化,写个模板。我不明白为什么加一个book数组标记一下就会wa,不加标记就ac,求大佬解答。#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;queue&gt;#include&lt;stack&gt;#include&lt;map&gt;#include&lt;vector&gt;#incl...

2018-11-25 12:06:18 126

原创 HDU Today HDU - 2112

用的map映射为整数,后面就和普通的最短路一样的,注意头文件。#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;cstring&gt;#include&lt;cmath&gt;#include&lt;algorithm&gt;#include&lt;stack&gt;#include&lt;queue&gt;#inc

2018-11-24 11:49:59 162

原创 最短路堆优化

MPI Maelstrom POJ - 1502 用不着堆优化也能过,就是想练一下手,上个题的最短路用堆优化过不了,求大佬解答#include&amp;lt;iostream&amp;gt;#include&amp;lt;cstdio&amp;gt;#include&amp;lt;cstring&amp;gt;#include&amp;lt;cmat

2018-11-23 20:45:39 325

转载 I love sneakers! HDU - 3033

分组背包的问题,一开始没想到,看到有个大佬写的挺好的,他是这样写的:分组背包问题,大意**要买鞋,有k种牌子,每种牌子至少买一双鞋子。每双鞋子有标价跟实际价值。求用m多的钱买最多价值的鞋。其实我觉得这题的难点就在处理“至少”这点上面。状态方程很多都能推出用 dp[k][m] 来表示 已经买了k种鞋 在有m钱状态下的 鞋的最大价值。状态转移方程为 for( k = 1 ; k &lt...

2018-11-18 10:40:04 177

原创 ACboy needs your help

ACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to arrange the M days for ...

2018-11-17 21:30:11 145

原创 CodeForces - 987 C.Three displays

这是思维题吗,用的动归的的#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;cstdio&gt;#include&lt;cstring&gt;#include&lt;math.h&gt;using namespace std;#define INF 1e9+5struct node{ int s,c;...

2018-11-17 21:28:02 246

原创 Cash Machine POJ - 1276

的用二进制思想进行优化,要不然会tl#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;cstdio&gt;#include&lt;cstring&gt;#include&lt;math.h&gt;using namespace std;#define N 1e9+5int w[10005],dp[100005]...

2018-11-17 21:22:05 206

原创 赞迪卡之声妮莎与奥札奇

链接:https://ac.nowcoder.com/acm/contest/218/B来源:牛客网奥札奇军团降临!赞迪卡陷入危机!无尽轮回钨拉莫和真理屠夫寇基雷带领着这群庞大的掠食者在赞迪卡肆意破坏。旅法师妮莎瑞文必须要阻止这一切。 在赞迪卡时空的一角,有 n 个寇族的部落。为了抵御奥札奇的进攻,这些部落之间联系密切。在任意两个部落之间都有一条直接道路相连接。换句话...

2018-11-17 12:40:16 581

原创 地,颜色与

链接:https://ac.nowcoder.com/acm/contest/218/A来源:牛客网现在,你作为一名新星鹏洛客,找到了一块绝佳的修炼地。这块地方可以被描述成一个 n x m 的矩形。你已经在这块地中的一些位置打好了标记。接下去,就该对整块地赋予你的颜色了。一个位置能被赋予你的颜色,当且仅当满足以下条件之一: 1. 这个位置被打上了标记。 2. 这个位置在不经过被...

2018-11-17 12:37:15 186

原创 数塔 HDU - 2084

数塔问题,dp,我从上往下推的,貌似从下往上推更简单。#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;algorithm&gt;#include&lt;cstring&gt;using namespace std;int main(){ int c; scanf("%d",&amp;c); w...

2018-11-14 20:32:29 243

原创 Max Sum HDU - 1003

这个题有个分治的想法是o(nlogn),动态规划的想法是o(n),用动态规划就好了,一开始总是wa,是那个位置标记错了,当最大值变的时候再改变开始位置和最终位置。#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;algorithm&gt;#include&lt;cstring&gt;using namespace std;...

2018-11-14 19:57:35 124

原创 最大公约数GCD(51Nod - 1011)

直接用__gcd()就能过,头文件是algorithm.#include&lt;bits/stdc++.h&gt;using namespace std;int main(){ long long a,b,c; cin&gt;&gt;a&gt;&gt;b; c=__gcd(a,b); cout&lt;&lt;c&lt;&lt;endl;}...

2018-11-14 18:54:20 215

原创 Raising Modulo Numbers(poj1995)

大水题,直接快速幂#include&lt;iostream&gt;#include&lt;cstdio&gt;using namespace std;int ksm(int a,int b,int m){ a=a%m; int ans=1; while(b&gt;0){ if(b&amp;1){ans=(ans*a)%m;} a=(...

2018-11-14 18:37:19 145

原创 Tri Tiling (poj2663)

DescriptionInhow many ways can you tile a 3xn rectangle with 2x1 dominoes?Here is a sample tiling of a 3x12 rectangle.InputInput consists of several test cases followed by a line containing -1. Ea...

2018-11-13 21:55:13 170

原创 Pie (poj3122)

DescriptionMy birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party ...

2018-11-13 20:55:47 276 1

原创 Array Product (CodeForces - 1042C )

Array ProductYou are given an array aa consisting of nn integers. You can perform the following operations with it:Choose some positions ii and jj (1≤i,j≤n,i≠j1≤i,j≤n,i≠j), write the value of ai⋅aja...

2018-11-13 20:39:19 177

原创 Booking System(贪心)

Booking System CodeForces - 416CInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!A restaurant called “Dijkstra’s Place” has sta...

2018-11-13 20:05:40 436

原创 排序

第一次写博客,就先写一下排序,最近写代码的时候碰到那种需要二级排序的,用结构体把数据存起来就可以开始排序了,代码是这样的:#include&amp;amp;lt;algorithm&amp;amp;gt;#include&amp;amp;lt;iostream&amp;amp;gt;using namespace std;struct node{ int x,y; bool operator&amp;amp;lt;(const

2018-11-13 19:47:30 207

空空如也

空空如也

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

TA关注的人

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