- 博客(13)
- 收藏
- 关注
转载 LCA最近公共祖先
Leetcode 236 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), ...
2019-04-27 11:57:43
203
原创 c++ int convert to string
1019 数字黑洞 (20 分) 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。例如,我们从6767开始,将得到7766 - 6677 = 1089 9810 - 0189 =...
2019-03-15 18:03:26
591
原创 A1029 Median
1029 Median (25 分) Given an increasing sequence S of N integers, themedian is the number at the middle position. For example, the medianof S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9,...
2019-03-14 19:47:33
165
转载 树状数组
https://blog.youkuaiyun.com/Yaokai_AssultMaster/article/details/79492190#include <cstring>#include <cstdio>///用于区间求和int data[200002];int C[200002];int lb(int x)///lowbit 用来求二进制的末尾0的个数 求的...
2019-03-13 20:21:04
124
原创 A 1067 Sort swap(0)
1067 Sort with Swap(0, i) (25 分)Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use...
2019-03-12 13:39:06
140
原创 cmp函数写法扩展(实现一个cmp的多次比较)
struct node {int id;int grade;};bool cmp(struct node n1, struct node n2){if (n1.grade > n2.grade)return n1.grade > n2.grade;elsereturn n1.id > n2.id;}
2019-03-02 13:30:50
698
原创 带空格字符串输入:getline(cin, str);
PAT1077A1077 Kuchiguse (20 分)The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personalit...
2019-03-02 13:10:02
318
原创 时间类的题目可以使用字符串进行处理
1006 Sign In and Sign Out (25 分)At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the recor...
2019-02-28 21:11:06
98
原创 int-> string
int a = 19;stringstream ss;ss << a;string str = ss.str();cout << str;
2019-02-27 21:55:32
367
转载 PAT B1008
1008 数组元素循环右移问题 (20 分)一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式:每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第2行输入N个整数,之间用空格分隔。输出格式:在一行中输出循环右移M位以后的整数序列,之间用空格分隔...
2019-02-26 21:17:58
124
原创 sscanf && ssprintf && 数组传参 && 结构体初始化 && 区分引用和指针
sscanf(str, “%d”, &amp;amp;n); //str-&amp;gt;int(int only, if double-&amp;gt;int(floor))sprintf(str, “%d”, n); //int-&amp;gt;str(only int, if double-&amp;gt;int(floor))
2019-02-25 20:39:54
294
原创 数组集成初始化汇总
1、迭代for循环2、 memset(a, 0, sizeof (a)) /*因为memset函数按照字节填充,所以一般memset只能用来填充char型数组,(因为只有char型占一个字节)如果填充int型数组,除了0和-1,其他的不能。因为只有00000000 = 0,-1同理,如果我们把每一位都填充“1”,会导致变成填充入“11111111”*/3、 int arr[...
2019-02-25 20:15:48
333
原创 First temp
This is my first tech-blog, hoping can witness my progress in coding
2019-02-25 20:04:14
109
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人