
水
stloztoeplitz
严格标准不抱怨,宽松要求自提高
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
期末考计划
共10题 保底6道 最后一题可以选择性放弃; 注意以下几点: 1读完所以题,有思路,有多条思路(防卡机)才开题,打好草稿; 争取简单的一次AC 2注意易错点 循环变量的设置,数组越界等,; 3时间问题 10道共180分钟, 每道 近20分钟(放弃最后一道) 4递归 参数具有可变性原创 2016-01-15 17:46:34 · 281 阅读 · 0 评论 -
矩阵连乘
方法一:采用了递归的方法,运到做括号就递归一下,在一次递推中先确定头数,遇到有括号返回递归结果。 gets()函数与C++中的getline差不多适合忽略空格的字符串输入 gets()的说明#include <stdio.h> #include <cstring> int ans;const int maxn = 200; char s[maxn]; char* sp; struct M {原创 2016-10-27 23:07:41 · 271 阅读 · 0 评论 -
1003. 射击游戏
实际就是求解卡特兰数。 一下搬自百度百科: 一个栈(无穷大)的进栈序列为1,2,3,…,n,有多少个不同的出栈序列?常规分析首先,我们设f(n)=序列个数为n的出栈序列种数。(我们假定,最后出栈的元素为k,显然,k取不同值时的情况是相互独立的,也就是求出每种k最后出栈的情况数后可用加法原则,由于k最后出栈,因此,在k入栈之前,比k小的值均出栈,此处情况有f(k-1)种,而之后比k大的值入栈,且都原创 2016-10-19 22:44:10 · 408 阅读 · 0 评论 -
10.20英语日常
1 donate he appeald to other leaders to donate to the cause 2stride It was by one stride that abrahams won the gold 3imaginative 4desire 5affiliate Beacause I am just too lazy to sign up for原创 2016-10-21 00:44:14 · 609 阅读 · 0 评论 -
Binary Tree
必须用除法才行,简单的加减法会超时#include <stdio.h> int l,r; void f(int a,int b) { l=r=0; int k; while(a!=1||b!=1) { if (a>b) { k = a/b; if(b==1) { l+=k-1; break原创 2016-11-16 20:48:15 · 203 阅读 · 0 评论 -
c风格字符串的赋值方式
1.对于c风格字符串,通常有如下几种赋值方法(字符串(双引号括起来的)都是以’\0’结尾的!!)char p[]=”abcde”;这里“abcde”是个常量字符串,存储在常量区。字符串的结尾都是带‘\0’的,只是没有显示而已,p是个数组。这里的意思是把此常量字符串值复制一份存储在数组p中,p的最后一个位置存储的是‘\0’,数组长度为6。char p[]={‘a’,’b’,’c’,’d’,’e’};这转载 2016-10-21 22:49:47 · 647 阅读 · 0 评论 -
谈谈外表协会的重要性
In such a apperance-first society,you could't blame it that other judge you only the first impression.Therefore, you have to be patient and careful well papered.Most importantly, Confidence is the key原创 2016-11-21 23:51:11 · 282 阅读 · 0 评论 -
3n+1数链问题
用时间换空间,然而需要的空间太大,卡在第6个样例,我觉得应该可以压缩的。#include <stdio.h> #include <string.h>int const maxn = 7000000; //不知道上限在哪里 int g_a[maxn]; int g_i,g_j; int g_ans=0;int dfs(int i) { if (g_a[i]!=-1) return g_a[原创 2017-02-27 13:33:37 · 365 阅读 · 0 评论 -
头条笔试题目
2018/8/25 发下头条的笔试题目,给大家笔试后练习。 第一题: 求连通分量。bfs dfs 并查集都可以。n=1e5,图的储存估计要用邻接表,而并查集开个数组就可以了。 第二题: 感觉应该是递推 唯一分解,考虑最后一个加减号的位置。 第三题: 听说kmp可以或者trie树 第四题: 不递减的序列的改变,记录一个周期每个点对应的大小关系,有上一个周期的节点就...原创 2018-08-29 10:47:41 · 323 阅读 · 0 评论 -
stl中vector的函数
STL之vector容器详解 ector 容器vector是C++标准模版库(STL,Standard Template Library)中的部分内容。之所以认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单的说:vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。使用vector容器之前必须加上头文件:#include;vector属于std命名域的内容,因此需要通过命转载 2016-10-16 13:22:43 · 356 阅读 · 0 评论 -
大数加法
method1: 链表,设置尾指针,从低位计算,达到标志是就停止#include <iostream> #include <string> using namespace std;struct ListNode { int val; ListNode* left; ListNode(int a):val(a),left(NULL){} };typedef ListNode原创 2016-10-16 17:18:34 · 357 阅读 · 0 评论 -
1934. 移动小球
#include <iostream> using namespace std;const int maxn_1= 500010; const int maxn_2=100010; int _left[maxn_1],_right[maxn_1];void link (int a, int b) { _right[a] = b; _left[b] = a; }int main() {原创 2016-10-16 15:29:40 · 278 阅读 · 0 评论 -
sicily 递归练习 1005. Arithmetic Expression Evaluation
Description Arithmetic expression can be defined recursively as following: (1) If a is a positive integer number, then a is an arithmetic expression. (2) If a is a negative integer number原创 2016-01-15 17:48:03 · 404 阅读 · 0 评论 -
寒假刷题计划
1刘汝佳的《算法竞赛入门》 2online judge uja (刷完书上的题) 洛谷(刷完提高区)原创 2016-01-15 17:53:42 · 415 阅读 · 0 评论 -
P1025 数的划分
将整数n分成k份,且每份不能为空,任意两个方案不相同(不考虑顺序)。 例如:n=7,k=3,下面三种分法被认为是相同的。 1,1,5; 1,5,1; 5,1,1; 问有多少种不同的分法。 n,k (6 输出格式: 一个整数,即不同的分法。 剪枝1:如果当已划分的数的和已经超过N 则不继续划分 剪枝2:最后一位时不进行搜索 直接判断出答案 i转载 2016-01-17 11:58:16 · 425 阅读 · 0 评论 -
1003. Maze
简单而基本的bfs问题,是求解这类问题的基本问题。许多bfs问题都是在这个问题上面衍生而来的。#include<iostream> #include<queue> using namespace std; int const maxn = 40; int a[maxn][maxn]; int isvis[maxn][maxn]; int dr[] = {-1,0,1,0}; int dc[] = {原创 2016-10-21 22:30:24 · 262 阅读 · 0 评论 -
kmp算法
#include <iostream> using namespace std; const int maxn = 60010; int s[maxn],a[maxn]; int * bulid(int* s,int len) { int * next = new int[len]; next[0] = -1; int p = 0; int k = -1;原创 2016-10-23 19:30:55 · 233 阅读 · 0 评论 -
卡片游戏
由于只对表头操作,可以用数组来模拟队列#include <iostream> using namespace std;int const maxn = 1000; int main() { int t; cin>>t; while (t--) { int n; cin>>n; int a[maxn]; for (int i=1;原创 2016-10-24 13:33:26 · 299 阅读 · 0 评论 -
1211. 商人的宣传
我记得这是离散数学课上学过的知识,好像是图的那章,关于连通性问题。而且还有更为快速的算法。 本题实际就是计算路径长度为l的从起点到末点的路径的条数。可以有属性归纳法证明,该解法的正确性。#include<iostream> #include<cstring> using namespace std; int const maxn = 500; int a[maxn][maxn]; int ans[原创 2016-10-25 22:16:50 · 286 阅读 · 0 评论 -
hit or miss 解题报告
hit or miss 解题报告 方法一:#include<iostream> using namespace std; const int maxn=10010; const int maxm=15; int i,j,k,m,n; int sum; int head[maxm],tail[maxm],counter[maxm]; int f[maxm][maxn];int check(int c原创 2016-10-16 00:09:00 · 1283 阅读 · 1 评论 -
1443. Printer Queue
method 1: 数组模拟队列,优点:效率高,代码简单。#include <iostream> #include <algorithm> using namespace std;const int maxn = 1000;bool cmp(int a,int b) { return a>b; }int main() { int t; cin>>t; while (原创 2016-10-16 14:59:17 · 317 阅读 · 0 评论 -
高精度模板
#include <bits/stdc++.h> using namespace std; string add(string s1,string s2) { int l1 = s1.size(); int l2 = s2.size(); if(l2>l1) { int n = l2-l1; while(n) ...原创 2018-09-14 13:35:32 · 258 阅读 · 0 评论