↓ Skip to main content

Posts

2017

archlinux安装记

·167 words·1 min
实在不忍心x1c吃灰。。。 打算装个arch玩。。。 第一次失败了,原因是忘记配置引导相关… 第二次就成功了… 教程满大街都是就不再写了….

qt 5.x初探 (3)

·677 words·2 mins
update3: 终于知道了正确的学习姿势… 用百度把要用的东西大概描述出来,然后总能找到一个是你要的。。。 然后再去搜关键词。。。 嗯。。百度还是很有用的啊2333 qt5.8_doc_Line Edits Example 所以现在要把之前写成dialog的几个改回Line edit

g++ 编译多个源文件(转载)

·1369 words·3 mins
参考资料 一. 常用编译命令选项 假设源程序文件名为test.c。 无选项编译链接 用法:#gcc test.c 作用:将test.c预处理、汇编、编译并链接形成可执行文件。这里未指定输出文件,默认输出为a.out。

qt 5.x 学习笔记 (2)

·3095 words·7 mins
先来放一波过程中用到的资料和官方文档好了。 basic layout_qt5.8 QBoxLayout Class_qt5.8 QString Class 5.8 QChar Class qt 5.8 Standard Dialogs Example qt 5.8 更新的部分还是放在最前面好了。 convert from QString to char *的时候有个坑。 In order to convert a QString to a char*, then you first need to get a latin1 representation of the string by calling toLatin1() on it which will return a QByteArray. Then call data() on the QByteArray to get a pointer to the data stored in the byte array. See the documentation: See the following example for a demonstration:

qt 5.x 初探(1)

·477 words·1 min
嘛。。为了系统安全课来学一波qt… 现在算是写出了一个可以打开文件,保存文件的记事本。 接下来要搞定的事情是,如何写一个自定义的事件?比如计算个开方之类的。

codeforces #413 C. Fountains (BIT维护前缀max)

·960 words·2 mins
题目链接 题意:有2种货币,分别为C和D.给出n种资源的代价和美丽度,每种资源只能用其中一种资源购买。现在拥有货币C的数量是c,拥有货币D的数量是d.然后恰好买2个资源,问最大美丽度,不能的话输出0.

codeforces #413 B T-shirt buying (贪心)

·699 words·2 mins
题目链接 题意:有n个T恤,每个价格都不同,有三种颜色,分别用1,2,3表示,每件T恤给出前xiong和后背的颜色。现在有m个顾客排成一队,对于每个顾客,给出他喜欢的颜色,只要一个T恤的前xiong或者后背的颜色之一满足该颜色即可。顾客总希望买符合他喜欢颜色的T恤中价格最低的。现在问每个顾客买到的T恤的价格,如果某个顾客没有买T恤,输出-1

codeforces #413 A. Carrot Cakes (模拟)

·391 words·1 min
题目链接 题意:初始有一个锅,每t分钟可以做好k个饼,现在需要N个饼。还可以另外建一个锅,花费d时间,建好以后两个锅可以并行烙饼。问是否应该建锅?(以期减少烙饼时间) 思路:求出两种情况下的总时间,比较一下。

20170504近况

·630 words·2 mins
啊。。在准备考试QAQ 明天约了鹅厂面试。。。然而从四月就开始一直考试考试考试….感觉药丸啊? MS的结果貌似明天也要出了orz… 之前没收到positive以为是跪了,结果听说有人没收到positive也拿到了offer啊?

ubuntu 包管理(apt-get)损坏的解决办法

·287 words·1 min
症状是不管安装什么,都会说有一大堆依赖无法安装。。。 大概是: a depends b[i],but b[i] is not be installed. (b==0..n) 最后会提示Unable to correct problems, you have held broken packages 解决办法:用synaptic工具,把可能存在问题的包都清除掉。

install galliumOS on chromebook with chrx

·538 words·2 mins
我的chromebook 是 samsung 3 查阅Hardware Compatibility 可以知道我的cb支持 gallium,对应的cpu 是Intel Braswell 然后去galliumos 官网 下载相应版本。 (发现这种做法并不需要自己下载。。。) 安装 galliumOS大体有两种方法,一种是完全去掉chromeOS,这种方法需要拆机去除写保护。。。我嫌麻烦。。。于是打算另一种,使用chrx 

20140419

·117 words·1 min
最让你恶心痛苦的那些人,你必要从他们身上学到最重要和有用的东西。 所有的痛苦都不能白受,克我者必生我。 在知乎看到这句话,不禁在想 人无疑是zhangk,可是学到了什么呢?

leetcode162. Find Peak Element (O(lgn)复杂度寻找峰值)

·448 words·1 min
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine that num[-1] = num[n] = -∞. For example, in array [1, 2, 3, 1], 3 is a peak element and your function should return the index number 2.

leetcode 152. Maximum Product Subarray (最大连续子序列乘积,dp)

·289 words·1 min
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6. 思路:由于有正,有负,还有0.。。所以比最大子串之和要复杂一些。。。 dp[i].max表示到当前位置的最大乘积。

leetcode 228. Summary Ranges

·412 words·1 min
Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 题意:把连续的数连续表示 思路:模拟。注意有负数,注意有-2147483648这种数据。 本来还想着,可能是leetcode加数据的审核机制太松,导致被人加了奇怪的数据。。。

leetcode 209. Minimum Size Subarray Sum (尺取法)

·248 words·1 min
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, given the array [2,3,1,2,4,3] and s = 7, the subarray [4,3] has the minimal length under the problem constraint 思路:尺取即可。。好久没写,竟然调了半天。。。 代码实现 1/* *********************************************** 2Author :111qqz 3Created Time :2017年04月13日 星期四 20时48分00秒 4File Name :209.cpp 5************************************************ */ 6class Solution { 7 8public: 9 10 int ruler(vector<int>nums,int tar,int n) 11 { 12 int head = 0; 13 int tail = 0; 14 int sum = 0 ; 15 int res = 0x3f3f3f3f; 16 while (tail<n&&head<=tail) 17 { 18 sum = sum + nums[tail]; 19 if (sum>=tar) 20 { 21 res = min(res,tail-head+1); 22 while (sum>=tar&&head<tail) 23 { 24 sum-=nums[head]; 25 head++; 26 } 27 if (sum>=tar) 28 { 29 res = min(res,tail-head+1); 30 } 31 else 32 { 33 head--; 34 sum+=nums[head]; 35 res = min(res,tail-head+1); 36 } 37 } 38 39 40 41 tail++; 42 } 43 return res==0x3f3f3f3f?0:res; 44 } 45 46 47 int minSubArrayLen(int s, vector<int>& nums) { 48 int n = nums.size(); 49 int res = ruler(nums,s,n); 50 return res; 51 52 53 } 54 55};

leetcode 75. Sort Colors

·628 words·2 mins
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. 题意:一个数组,由0,1,2组成,现在要求升序排列 思路:无脑做法就是计数排序,扫两遍,时间复杂度O(n),空间复杂度O(1)