自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

MKFMKIKU的博客

算法记录用

  • 博客(34)
  • 收藏
  • 关注

原创 CodeForces 442 div2 记录

这次CF感觉挺简单的,但是我思路不够宽A. Fake NPTavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.You are given l and r. For all integers fro

2017-05-05 09:09:48 605

原创 身份证纹理去除思路探究

初步过滤经过研究观察模拟,发现身份证照片纹理是基于(150,150,150)的画笔绘制出来的,所以我们先用闸值过滤掉大于这个值的像素,同时应用闭操作解决波纹不纯的问题allMask = cv2.cvtColor(demo,cv2.COLOR_RGB2GRAY)ret,thresh = cv2.threshold(allMask,150,255,cv2.THRESH_BINARY)allMask

2017-04-30 21:18:11 2628 1

原创 Codeforces 补题 Educational Round 19

Problem-A Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n. Input The first li

2017-04-23 08:58:17 465

原创 CodeForces Round #401 补题

Problem A:#include <cstdio>#include <iostream>using namespace std;#define F(i,a,b) for(int i=a;i<b;i++)int main(){ int n,x; scanf("%d%d",&n,&x); n %= 6; while(n--){ if(n & 1)

2017-03-09 10:02:38 216

原创 CodeForces Round #403 补题

Problem A :#include <cstdio>#include <iostream>#include <cstring>using namespace std;#define F(i,a,b) for(int i=a;i<=b;i++)#define maxn 100005int main(){ int n,num[2*maxn]; scanf("%d",&n);

2017-03-06 21:21:20 269

原创 CodeForces Round402 补题

Problem A:#include <cstdio>#include <cstring>#include <cmath>#include <iostream>using namespace std;int main(){ int n,a[6],b[6]; scanf("%d",&n); memset(a,0,sizeof(a)); memset(b,0,si

2017-03-05 21:27:52 257

原创 数论初步

GCD算法:int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}唯一分解定理: 算术基本定理可表述为:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积 推论:最小公倍数LCMgcd(a,b)∗lcm(a,b)=a∗b gcd(a,b)*lcm(a,b) = a*b Eratosthenes 筛法:对于不超过n的每

2017-03-05 20:13:47 193

原创 数论初步

GCD算法:int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}唯一分解定理: 算术基本定理可表述为:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积 推论:最小公倍数LCMgcd(a,b)∗lcm(a,b)=a∗b gcd(a,b)*lcm(a,b) = a*b Eratosthenes 筛法:对于不超过n的每

2017-03-04 17:12:13 177

原创 DFS/BFS 搜索训练

hdu 1016:#include <cstdio>#include <iostream>#include <cstring>using namespace std;int prime[40]={0,0,1},vis[40],num[40],n;void checkPrime(){ for(int i=3;i<=40;i++){ prime[i]=1;

2017-03-03 15:40:57 207

原创 动态规划练习

参考资料:http://www.hawstein.com/posts/dp-novice-to-advanced.html硬币问题:int main(){ int num[3]={1,3,5}; int now=0; int d[15]; for(int i=0;i<=11;i++) d[i]=i; for(int i=0;i<=11;i++)

2017-03-02 15:08:56 204

原创 UVA 11572

滑动窗口问题题目:https://uva.onlinejudge.org/external/115/11572.pdf比较简单 自己体会#include <iostream>#include <cstdio>#include <set>using namespace std;int main(){ int CASE,n,a[1000005]; scanf("%d",&CASE

2016-10-26 16:39:17 272

原创 UVA 11054 搬酒问题

题目: https://uva.onlinejudge.org/external/110/11054.pdf题目思想挺纯粹的,就是等价转换法#include <cstdio>#include <cmath>#include <iostream>using namespace std;typedef long long LL;int main(){ int n; while (~

2016-10-25 12:26:41 247

原创 UVA 11134 下棋

题目:https://uva.onlinejudge.org/external/111/11134.pdf题目这里的思想是棋盘摆放时x轴和y轴互补影响,看成一个贪心问题就行了。#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>using namespace std;struct node{

2016-10-24 13:31:04 244

原创 UVA 1152 数组和

一个有趣的题目,时间要求是9s,数据特别大,只有 O(n2logn) O(n^2logn) 才能过 Accepted C++11 2.680 2016-10-23 00:46:48 题目:https://uva.onlinejudge.org

2016-10-23 08:51:32 267

原创 UVA 120 煎饼

题目比较简单,容易弄混顺序之间的关系原理是从后向前扫描,当遇到不符合顺序的,就把它移动到合适的地方,这样从后向前,就一定能排出符合顺序的煎饼果子。题目链接:https://uva.onlinejudge.org/external/1/120.pdf#include <cstdio>#include <iostream>#include <algorithm>using namespace st

2016-10-22 17:13:26 325

原创 卡特兰数

卡特兰数又称卡塔兰数,是组合数学中一个常出现在各种计数问题中出现的数列。由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名。In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often

2016-09-01 00:00:52 209

原创 POJ 2253

这题属于 shortest path problem的一种,我并没有用 dijkstra 而是 floyd 求解。 时间复杂度略逊 O(|V|3)O(|V|^3)#include <cstdio>#include <cmath>#include <algorithm>using namespace std;struct coordinate_type{ int x; int

2016-08-11 22:54:55 176

原创 POJ 2387

入門級的最短路。這裡為了學習我使用了帶有 min-priority queue的方法將時間複雜度優化至 O(∣∣E∣∣+∣∣V∣∣log∣∣V∣∣)O(\begin {vmatrix} E \end {vmatrix} +\begin {vmatrix} V \end {vmatrix} \log\begin {vmatrix} V \end {vmatrix})#include <cstdio>

2016-08-11 08:08:46 134

原创 UVA 11624

两次BFS,一次记录火在不同的时间蔓延的地方。第二次搜索最短路线。#include <cstdio>#include <iostream>#include <cstring>#include <queue>#include <vector>using namespace std;struct Node{ int x,y;};char map[1005][1005];int fi

2016-08-09 18:19:18 215

原创 POJ 3087

这题的界线不是很清楚。到底属于模拟还是搜索呢?16ms模拟水过23333#include <cstdio>#include <iostream>#include <map>#include <cstring>using namespace std;const int maxn = 10000;int main(){ int T,n; scanf("%d",&T);

2016-07-27 20:06:33 172

原创 POJ 1426

一道BFS题。要从数据的构成考虑#include <cstdio>#include <iostream>#include <queue>using namespace std;typedef long long LL;void bfs(int n){ queue<LL> q; q.push(1); while(!q.empty()){ if(q.f

2016-07-16 14:54:15 199

原创 POJ 3279 题解

一个简单的搜索,通过查找第一行的全部可能确定后面的选择。#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN=1000000000;int M,N;int map[20][20],r[20][20],ans[20][20];int dx[]={-1,0,0,0,1}

2016-07-08 17:55:50 444

原创 POJ 3278

这题以前写过,很简单的BFS。就是可能不容易想到。还是那么一句话,最短路,BFS。AC比较轻松,算是BFS的练手题吧。#include <cstdio>#include <iostream>#include <queue>#include <cstring>using namespace std;#define maxn 100005int n,k;queue<int> q;int s

2016-06-28 09:33:08 159

原创 POJ 2251 简单BFS

这题虽然题目大,但是其实只是一道BFS最短路径的裸题。BFS之所以能求最短路是因为它采用广度优先搜索,每次接触到的面时间都是相等的。所以在找的目的地时一定是最短路径。代码如下//// main.cpp// Code//// Created by KFM on 16/6/25.// Copyright © 2016年 KFM. All rights reserved.//#incl

2016-06-25 20:50:52 243

原创 Python爬虫折腾纪录

用于远程下载图片的函数import urllibimport redef downImg(url,name): urllib.urlretrieve(url,name);

2016-05-02 20:07:16 268

原创 哈希表

哈希表又叫散列表,关键值通过哈希函数映射到数组上,查找时通过关键值直接访问数组。#include <iostream>#include <string>using namespace std;class HashTable {private: string *elem; int size;public: HashTable() { size = 20

2016-04-25 21:01:02 223

原创 数据结构-栈

简单的栈的实现在里面使用了模版定义:模板是C++支持参数化多态的工具,使用模板可以使用户为类或者函数声明一种一般模式,使得类中的某些数据成员或者成员函数的参数、返回值取得任意类型。#include<iostream>#include<string>#include<cassert>using namespace std;template<class Type> class Stack {p

2016-04-18 22:28:52 223

原创 数据结构-队列

First in First Out#include <iostream>using namespace std;class Queue{ private: int * data; int head,tail,length; public: Queue(int length_input){ data = new

2016-04-11 23:57:55 197

原创 数据结构-链表

在链表中元素相互依赖,串联而成。#include<iostream>using namespace std;class Node {public: int data; Node* next; Node(int _data) { data = _data; next = NULL; }};class LinkList {pri

2016-04-11 23:08:18 295

原创 数据结构-线性表

简单构造的顺序表#include <iostream>#include <cstring>using namespace std;class Vector {private: int size, length; int *data;public: Vector(int input_size) { size = input_size;

2016-04-10 09:38:39 334

原创 Uva816 Abbott的复仇

https://uva.onlinejudge.org/external/8/816.pdf题目据说是2000年的World Finals,所以题目特别长,看着看着几乎睡着。题意:一个包含最多9*9个交叉点的迷宫,输入起点,离开起点的方向和终点。求最短路。要求:进入一个交叉点的方向不同,允许出去的方向也不同Sample Input: SAMPLE 31N33 1 1 WL NR *

2016-04-08 07:37:18 929

原创 Uva699 839二叉树的遍历

这题主要是在数据的读取上可能会比较犯难想懂以后就简单了。https://uva.onlinejudge.org/external/6/699.pdf/* *树叶问题 *Uva699 */#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define maxn 150int sum[ma

2016-04-06 21:46:15 223

原创 PythonOJ尝试

OJ:http://nanti.jisuanke.com/ 这里python接受到的输入都是字符串,需要转化成intA+B+C# coding=utf-8a=raw_input().split()print int(a[0])+int(a[1])+int(a[3])整除问题# coding=utf-8f = raw_input().split()a = int(f[0])b = int(f[

2016-04-04 20:10:09 539

原创 Uva221矩形个数判断

这题我本来想的是如何储存的,在储存中寻找解决方案,结果在一番思考毫无思路以后,在google中发现了方案很简单。存数组,在读取时判断。#include <cstdio>#include <iostream>#include <cstring>using namespace std;int H[10][10], V[10][10];int main() { //freopen("cin"

2016-04-03 18:37:19 476

空空如也

空空如也

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

TA关注的人

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