![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
weixin_39742952
这个作者很懒,什么都没留下…
展开
-
int-> string
int a = 19;stringstream ss;ss << a;string str = ss.str();cout << str;原创 2019-02-27 21:55:32 · 332 阅读 · 0 评论 -
树状数组
https://blog.csdn.net/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 · 83 阅读 · 0 评论 -
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 · 118 阅读 · 0 评论 -
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 · 569 阅读 · 0 评论 -
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 · 116 阅读 · 0 评论 -
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 · 107 阅读 · 0 评论 -
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 · 670 阅读 · 0 评论 -
带空格字符串输入: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 · 302 阅读 · 0 评论 -
时间类的题目可以使用字符串进行处理
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 · 75 阅读 · 0 评论 -
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 · 152 阅读 · 0 评论