- 博客(6)
- 收藏
- 关注
原创 算法训练 2的次幂表示
作者:秒针的声音 时间:2015-3-28问题描述 任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001。 将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0 现在约定幂次用括号来表示,即a^b表示为a(b) 此时,137可表示为:2(7)+2(3)+2(0) 进一步:7=2^2+2
2015-03-28 16:19:22 1097
原创 k好数(动态规划)
#include<stdio.h>#include <math.h>#define mod 1000000007#define N 105int Num[N][N]={0};long long KGoodNumber(int k,int l){ long long cnt=0; int i,j,x; for(i=0;i<k;i++){Num[1][i]=1;}
2015-03-28 16:06:19 1238
原创 堆排序的数组实现代码
/*堆排序数组实现*/#include <stdio.h>#include <stdlib.h>#define N 8#define M N+1/*队列*/ int rear=N,front=(N+1)/2;//此处有N+1个已入队 void change(int *a,int *b){ int t; t=*a; *a=*b; *b=t;}/*调整
2015-03-12 22:08:57 1030
原创 C++责任链
#include <iostream>using namespace std;class Base{ protected: Base *next; public: Base(Base *t){ next=t; } Base(){
2015-03-08 23:17:06 974
原创 堆排序的链式实现
GCC编译通过:#include <stdio.h>#include <stdlib.h>#define N 10#define MAX 100typedef struct node{ int data; struct node *left; struct node *right;}BTnode;BTnode *queue[N+1];int rear=0,fro
2015-03-08 23:15:25 1133
原创 按层建树(堆排序基础)
按层建树是按照给定的数据数组来建立完全二叉树的过程。其中涉及到的基础知识有结构体的创建重命名以及使用、链表的创建和数组遍历。 实现代码如下: GCC编译通过:#include <stdio.h>#include <stdlib.h>#define N 10#define MAX 100typedef struct node{ int data; struct node
2015-03-08 23:13:36 1076
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人