算法类
文章平均质量分 57
dongfengkuayue
其实你不快乐的根源是因为你不知道要什么你不知道要什么所以你不知道去追求什么你不知道追求什么所以你什么也得不到
展开
-
A+B(HDOJ)
http://acm.hdu.edu.cn/showproblem.php?pid=1228模拟类字符串处理问题#include #include using namespace std;string num[]={"zero","one","two","three","four","five","six","seven","eight","nine"};int search原创 2014-03-12 11:26:57 · 749 阅读 · 0 评论 -
归并排序poj2299
<br /> Ultra-QuickSortTime Limit: 7000MS Memory Limit: 65536KTotal Submissions: 19252 Accepted: 6828<br />DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping原创 2011-03-25 21:34:00 · 824 阅读 · 0 评论 -
1002. A+B for Polynomials
http://pat.zju.edu.cn/contests/pat-a-practise/1002这题我一开始想了个极其愚蠢的办法,开两个数组然后把系数存储到对应的数组位置上,两个系数数组循环一遍非零的相加,然后发现这样做效率太低,网上参考了下,发现大神的做法只开一个数组,在从标准终端读数剧的时候就把相应的系数加好。#include#include#includeusing nam原创 2014-03-14 11:03:36 · 3035 阅读 · 1 评论 -
数据结构(1)线性表中的顺序表
写出顺序表的数据结构及其主要的操作实现:1.初始化顺序表 2.清空顺序表3.计算顺序表的长度4.判断表满否函数5.在表中顺序查找与值X匹配的元素6.函数返回第i(17.将新元素X插入到顺序表中第i(18.删除顺序表第i(19.复制表L2的全部内容到表L1原创 2013-03-06 21:28:21 · 874 阅读 · 0 评论 -
上取整和下取整
在数学和计算机科学中,取整函数是一类将实数映射到相近的整数的函数。[1]常用的取整函数有两个,分别是下取整函数和上取整函数。下取整函数在数学中一般记作或者,在计算机科学中一般记作floor(x),表示不超过x的整数中最大的一个。举例来说,,,,。对于非负的实数,其下取整函数的值一般叫做它的整数部分或取整部分。而叫做x的小数部分。每个分数都可以表示成其整数部分与一转载 2014-03-15 15:55:04 · 28737 阅读 · 0 评论 -
幻方
初學者的幻方例子 我們可以先由1些較容易的幻方開始~n階幻方特色:-- 方陣中的數字是由 1 到n乘n的連續整數組成。(數字不可重複)-- 方陣的行和、列和、對角線和都要等於定出來的總和。行和: 方陣中同1行的n個數字之和,共有n個行和。列和: 方陣中同1列的n 個數字之和,共有n個列和。對角線和: 方陣中同1條對角線的n個數转载 2014-10-26 15:06:05 · 719 阅读 · 0 评论 -
求最小公倍数的数学方法
a,b两数的最小公倍数为两数的乘积除以他们的zuid原创 2014-10-29 22:51:27 · 872 阅读 · 0 评论 -
btree
B~树 1.前言:动态查找树主要有:二叉查找树(Binary Search Tree),平衡二叉查找树(Balanced Binary Search Tree),红黑树 (Red-Black Tree ),B-tree/B+-tree/ B*-tree (B~Tree)。前三者是典型的二叉查找树结构,其查找的时间复杂度O(log2N)与树的深度相关,那么转载 2016-03-09 16:35:37 · 1640 阅读 · 0 评论 -
LCA(最近公共祖先)问题
http://poetrinity.diandian.com/post/2012-02-04/19684915LCA(最近公共祖先)问题LCA问题便是指,给定一棵树T和两个节点u和v,找出u和v的离根节点最远的公共祖先。 方法一:Tarjan离线算法 在学习离线算法的时候先需要先巩固一下深度搜索,并查集 Tarjan离线算法是基于深度优先搜索的,我们从根开始向下搜索转载 2016-05-26 16:29:31 · 417 阅读 · 0 评论 -
poj1006中国余数定理
BiorhythmsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 78980 Accepted: 23740DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and原创 2011-06-02 14:43:00 · 3876 阅读 · 0 评论 -
poj1520scramble_sort
Scramble SortTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1896 Accepted: 972DescriptionIn this problem you will be given a series of lists containing原创 2011-06-06 10:37:00 · 1168 阅读 · 0 评论 -
还是A+B(HDOJ)
http://acm.hdu.edu.cn/showproblem.php?pid=1229此题为模拟类。刚开始我的解答为:#include #include #include using namespace std;int main(int argc, char *argv[]){ int a=0,b=0,k=0; while(cin>>a>>原创 2014-03-12 15:04:37 · 821 阅读 · 0 评论 -
**火星A+B(HDOJ)
http://acm.hdu.edu.cn/showproblem.php?pid=1230感觉压根没看明白题目意思。原创 2014-03-13 16:12:58 · 1482 阅读 · 0 评论 -
C程序设计P265程序实现
// testn.cpp : 定义控制台应用程序的入口点。///*#include "stdafx.h"#include #include "stdlib.h"int _tmain(int argc, _TCHAR* argv[]){char a[100]; int b; scanf("%s",&a); b=atoi(a);printf("\n%d",b); retu原创 2013-03-13 17:17:20 · 995 阅读 · 0 评论 -
poj1799
Yeehaa!Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 8585 Accepted: 4427DescriptionBackground George B. wants to be more than just a good American. He wants to make his daddy proud and become a western hero. You know, like John Wayne. But snea原创 2011-06-02 22:27:00 · 1062 阅读 · 0 评论 -
poj1017 packets
装箱问题 问题描述 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个 型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. 这些产品通常使用一个 6*6*h 的长方体包裹包装然后邮寄给客户。因为邮费很贵,所以工厂要想方设法的减小每个订单运送时的 包裹数量。他们很需要有一个好的程序帮他们解决这个问题从而节省费用。现在这个程序由 你来设计。 输入数据 输入文件包括几行,每一行代表一个订单。每个订单里原创 2011-06-02 15:14:00 · 7849 阅读 · 3 评论 -
二叉树的应用与熟悉
一、二叉树的存储结构:1.顺序存储结构:适用于完全二叉树//-----二叉树的顺序表示------#define MAX_TREE_SIZE 100 //二叉树的最大结点数typedef TElemType SqBiTree[MAX_TREE_SIZE];//0号单元存储根结点SqBiTree bt; 2.链式存储结构//--------二叉树的二叉链表存储表示---------typedef struct BiNode{TElemType date;struct原创 2011-03-24 17:35:00 · 534 阅读 · 0 评论 -
哈希表的应用
<br /> EqsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 5678 Accepted: 2742<br />DescriptionConsider equations having the following form: <br />a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 <br />The coefficients are given integers from the interval [-50原创 2011-03-22 15:19:00 · 687 阅读 · 0 评论 -
【PAT】1001. A+B Format
PAT1001此题花费了很长时间,做了几次都是说超时,网上找了个答案找到毛病,while(true)是绝对不能用的,while(cin>>a>>b)可以用。#include #include #include #include using namespace std;int main(int argc, char *argv[]){ int a,b,sum,n,i;原创 2014-03-13 20:13:31 · 4597 阅读 · 4 评论 -
leetcode记录 231. Power of Two
public class Solution { public boolean isPowerOfTwo(int n) { if(n<1) return false; return ((n & (n -1)) == 0); }}需要注意的就是n如何判断一个数是2的幂,主要是要找出2的幂次方的数的特点。我们知道,1个数乘原创 2016-05-26 16:51:04 · 334 阅读 · 0 评论