- 博客(6)
- 收藏
- 关注
原创 [POJ] 3176 Cow Bowling
动态规划#include <iostream>#include <algorithm>using namespace std;int main() { int n; cin >> n; int ** sum = new int*[n]; sum[0] = new int; cin >> sum[0][0]; for (int i = 1; i
2016-06-30 20:36:27
218
原创 [leetcode]367. Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.class Solution {public: bool is
2016-06-28 12:11:19
339
原创 [leetcode] 368. Largest Divisible Subset
对于一个排好序的数列nums, nums[i] % nums[j] = 0 且 nums[j] % nums[k] = 0 则有 nums[i] % nums[k] = 0. 因此可以用动态规划: 用maxpos记录该子列的结尾元素下标; 数组num用num[i]记录以nums[i]为结尾元素的满足条件的子列的最大元素个数; 数组index用index[i]记录
2016-06-28 10:24:15
237
原创 Binary Tree
#include <iostream>using namespace std;class BinaryTree { private: struct treenode{ int key; treenode *left, *right; treenode (int k, treenode *l = 0, t
2016-05-25 20:05:40
160
原创 Bubble sort, Insertion sort, merge sort, quick sort, heap sort
#include <iostream>#include <algorithm>#include <cstdlib>#include <ctime>using std::cout;using std::endl;const int n = 80000;// bubblesortvoid bubble(int * a, int n) { for (int i = 0; i < n
2016-05-23 20:44:29
582
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人