- 博客(5)
- 收藏
- 关注
原创 二进制枚举子集
用二进制中1表示有,0表示无,数组作为集合可枚举所有子集。#include <cstdio>#include <string>#include <iostream>using namespace std;int a[5] = { 6,5,7,8,9 };void print(int s) { for (int i = 0; i < 5; ++i) { if (s &
2017-10-25 15:01:50 346
原创 C++string的坑点
string str,之前直接用str[k] = ‘\0’,实际上并没有改变string.length(); 如果这个时候直接cout << str,此时会打印其中的’\0’,而’\0’在内存中相当于一个空格。
2017-10-24 21:54:08 543
原创 快速排序优化
快速排序优化版。 1.从low,right,mid = (low + right) >> 1 中选择中间的数作枢纽。 2.将与枢纽相同的数通过先放入边缘两边,再放到枢纽旁边,防止重复数组带来的时间消耗。#include <cstdlib>#include <iostream>#include <cstdio>#include <ctime>using namespace std;int
2017-10-22 18:44:27 231
原创 A - Balanced Number HDU - 3709
A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is p
2017-10-13 17:10:37 307
原创 B - Points on Cycle
There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other you may ass
2017-10-03 20:58:53 282
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人