自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(39)
  • 收藏
  • 关注

原创 二叉树全部操作

#include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct Node { char value; struct Node *left, *right;} Node;Node *init(char value) { Node *root = (Node *)mal...

2018-03-08 14:07:32 255

原创 二叉树遍历(非递归)

#include <stdio.h>#include <stdlib.h>#include "any_stack2.h"typedef struct Node { int data; struct Node *lchild, *rchild;} Node;Node *getNewNode(int data) { Node *p = (N...

2018-03-08 14:04:20 193

原创 存储任意类型的栈

/************************************************************************* > File Name: any_stack2.h > Author: > Mail: > Created Time: 2018年02月28日 星期三 10时50分04秒 ********************...

2018-03-08 14:03:29 283

原创 快速排序(非递归)

#include <stdio.h>#include "any_stack2.h"void quick_sort(int *a, int left, int right) { //0 if (left >= right) return ; //100 int l = left, r = right, base = a[left]; while (l < r...

2018-03-08 13:59:11 213

原创 1和0的个数

/*************************************************************************    > File Name: test98.cpp    > Author:     > Mail:     > Created Time: 2018年01月30日 星期二 14时36分01秒 *****************

2018-01-30 20:45:14 297

原创 基数排序

#include #include void radix_sort(int *num, int n) {    #define maxn_n 65535    int *cnt = (int *)calloc((maxn_n + 1), sizeof(int));    int *temp = (int *)malloc(sizeof(int) * n);    for

2018-01-30 20:41:48 122

原创 哈希表

#include #include #include typedef struct HashTable { char **elem; int size;} HashTable;void init(HashTable *h);int hash(HashTable *h, char value[]);int search(HashTable *h, char valu

2018-01-30 20:18:23 171

原创 排序

/*************************************************************************    > File Name: 排序.cpp    > Author:     > Mail:     > Created Time: 2018年01月23日 星期二 19时06分58秒 *********************

2018-01-26 18:15:56 157

原创 DAY-04

找规律的题仔细观察并找到规律 代码如下:#include <stdio.h>#include <inttypes.h>int32_t GetLetterNum(int32_t i) { static int32_t LN20[20] = { 0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8

2017-11-13 11:02:35 138

原创 DAY - 03

滑动窗口法滑动窗口发例题/************************************************************************* > File Name: 滑动窗口.cpp > Author: qwq > Mail: > Created Time: 2017年11月07日 星期二 17时02分40秒 **********

2017-11-09 14:29:04 148

原创 DAY-02

数的进制转换与回文判断Double-base palindromes36辗转相除法Smallest multiple5素数筛与线性筛10001st prime素数筛:#include<stdio.h>#include<math.h>int main(){ int maxn = 200000; long long p[maxn] = {0}; for(long long i

2017-11-07 16:15:20 125

转载 文章标题

第七题Digit fifth powers这是求上限的问题bool is_vid(int x){ int n = x; int sum = 0; while(x) { sum += pow(x % 10, 5); x /= 10; } return sum == n;}void example7(){ in

2017-11-04 23:01:25 125

转载 文章标题

第六题Number spiral diagonalsbool is_vid(int x){ int n = x; while(x) { sum += pow(x % 10, 4); } return sum == n}

2017-11-04 22:48:12 109

转载 文章标题

第五题Sum square differencevoid example5(){ int sum1 = 0, sum2 = 0; for(int i = 1; i <= 100; i++) { sum1 += i * i; sum2 += i; } printf("%d", sum2 * sum2 - sum1);}

2017-11-04 22:45:32 109

转载 文章标题

第四题Largest palindrome productint is_huiwen(int x){ int high = pow(10, floor(log10(x))); int low; while(high > 0) { low = x % 10; int high1 = x / high; if(high1

2017-11-04 22:43:19 123

转载 文章标题

第三题Largest prime factor 我的做法,从后面开始找是不是因数,然后判断是不是素数bool prime(long long n){ long long i; for(i = 2; i <= sqrt(n); i++) { if(n % i == 0) return 0; else

2017-11-04 22:41:08 113

转载 文章标题

Even Fibonacci numbersint example2() //f[i] = f[i - 1] + f[i - 2] == f[i % 3] = f[(i - 1) % 3] + f[(i - 2) % 3];{ long long f[1000]; f[1] = 1, f[2] = 2; long long sum = 0; for(

2017-11-04 22:32:08 104

转载 文章标题

Next Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiple

2017-11-04 22:28:35 116

原创 高精度计算2 + 22 + 222 + 2222...(做法2)

这个想法是每一个数字与每一位数字(可以理解成我只算个位数字,然后通过进位D来改变比他优先级别高的数字),把高精度算法的  % 1000000 简化成 %10 看起来就很简单吧 是不是~具体代码如下:#includeusing namespace std;int add(int a[], int sum[]){ int d = 0; int i; for(

2017-11-02 13:44:29 1747

原创 高精度计算2 + 22 + 222 + 2222...(做法1)

如标题所示,正常我们的LONGLONG是有上限的,这就涉及到了我们需要用到大数据,具体怎么实现,我用数组进行模拟,每个数组存6位数字,从高位存到低位。算法如下#includeusing namespace std;int main(){ long long a[100]; long long sum[156]; /*for(int i = 0;

2017-11-02 13:33:38 1307

原创 递归打印螺旋数字

例如:1   2   38   9   47   6   5#include#includeusing namespace std;void print(int **a, int x, int y, int num, int n){ if(n <= 0) { return; } if(n == 1) {

2017-10-27 21:01:23 213

原创 简单的选择排序

简单的选择排序就是每次内层循环找出数组里最小或最大的数,将它的下表保存起来;然后与当前的数进行交换、代码如下:#includeusing namespace std;void Selectsort(int a[], int n){ for(int i = 0; i < n; i++) { int k = i; for(int

2017-10-27 18:20:37 123

原创 快速排序

#includeusing namespace std;int Div(int a[], int left, int right){ int base = a[left]; while(left < right) { while(left base) { right--; }

2017-10-27 18:09:41 111

原创 磁盘调度 C语言实现

#include #include #include using namespace std;void FIFO(int a[],int n){ int sum = 0; int i,j,now; float avg; cout << "请输入当前的磁道号:"; cin >> now; cout << "磁盘调

2017-06-07 16:39:58 1708

原创 哈工大答案

#include"stdio.h"#include"stdlib.h"#include"string.h"#includeusing namespace std;struct fri{ struct fri *f; struct fri *s; char num[20]; char name[20];};int main(){ char o

2016-05-11 07:42:28 1067

原创 哈工大作业题

#include#includestruct people{ char s1[10000]; char s2[10000]; char s3[10000]; char s4[10000]; int num[1000];} p[10000];char ex(char *a, char *b){ char *c; c = a;

2016-05-09 21:19:42 389

原创 重复画图

RepeaterTime Limit: 1000 MSMemory Limit: 65536 KTotal Submit: 70(21 users)Total Accepted: 33(18 users)Rating: Special Judge: NoDescriptionHa

2016-05-06 21:37:25 303

原创 竖式问题

B.竖式问题Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 1(1 users)Total Accepted: 1(1 users)Special Judge: NoDescription竖式问题是:有被乘数xyz和

2016-05-05 18:36:14 469

原创 HDU 1685

Problem DescriptionThe Leiden University Library has millions of books. When a student wants to borrow a certain book, he usually submits an online loan form. If the book is available, then the ne

2016-04-27 22:56:00 326

原创 HDU 1688

/*求s到t的最短路与次短路(这里要求只比最短路多1)的条数之和联想到最小,次小的一种更新关系:if(x<最小)更新最小,次小else if(==最小)更新方法数else if(x<次小)更新次小else if(x==次小)更新方法数同时记录s到u最短,次短路及方法数用一个堆每次取最小的,更新完后再入堆还是那个原理,第一次遇到的就是最优的,然后vi标记为真方法数注意是加法原

2016-04-27 22:52:28 301

原创 HDU 1686

Problem DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait

2016-04-27 22:48:21 149

原创 UVa 679 - Dropping Balls

题目:有一颗满二叉树,每个节点是一个开关,初始全是关闭的,小球从顶点落下,            小球每次经过开关就会把它的状态置反,现在问第k个球下落到d层时经过的开关编号。分析:进制编码。经过模拟几次可以看出,球会让开关形成连续二进制数的表示(根是低位)。            当放入第k个球时,开关状态正好是二进制的k,利用模2的余数判断走向即可。说明:观察规

2016-04-25 11:27:05 253

原创 HDU 4699

Problem Description Sample Input8I 2I -1I 1Q 3LDRQ 2 Sample Output23HintThe following diagram shows the status of sequence after each instruction:

2016-04-25 11:20:18 274

原创 uva 348

Optimal Array Multiplication SequenceGiven two arrays A and B, we can determine the array C = A B using the standard definition of matrix multiplication:The number of columns

2016-04-25 11:16:13 337

原创 uva 122 二叉树

Background背景Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-trees

2016-04-25 11:11:59 307

原创 FZU 2125 简单的等式

FZU 2125 简单的等式从小到大枚举s(x,m)的值,解出x的值,看看是否满足x^2+s(x,m)x-n=0,如果满足则输出x。因为1#include#include#define ll long longll s(ll x,ll m){ ll ans=0; while(x) { ans+=x%m;

2016-04-25 11:04:42 257

转载 FZU 1895

FZU 1895 整除45的问题先考虑末位,要能被45整除,那么肯定能被5和9整除,被5整除,末位定是0和5,被9整除,所有数字之和是9的倍数抓住这两点,DFS一边即可,注意剪枝#include #include #include using namespace std;const int N = 1005;const int M = 15;

2016-04-25 10:53:13 243

转载 csu 1542

题意:先给出一个符合括号匹配的字符串,然后Q次操作每次操作将某个括号反转,问将哪个括号反转能使字符串的括号再次匹配,位置要越靠近左端越好假如(表示数字1,)表示数字-1,A[i]表示前i个括号代表的数字之和((()))代表的数组A就是1 2 3 2 1 0那么这些数字会有什么用呢,,我们可以来找下规律如果是将(变成),如上面那个字符串的第2个反转

2016-04-24 11:29:50 198

原创 CSU 1538

#include#include#includeusing namespace std;#define N 2000int main(){#ifdef CDZSC freopen("i.txt","r",stdin);#endif int vis[N]; int n,m,a,b; scanf("%d%d",&n,&m); memset(vis,0,sizeof(vis))

2016-04-23 22:38:45 269

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除