![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
qq_17241443
这个作者很懒,什么都没留下…
展开
-
PythonOJ尝试
OJ:http://nanti.jisuanke.com/ 这里python接受到的输入都是字符串,需要转化成int A+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 · 514 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 264 阅读 · 0 评论 -
动态规划练习
参考资料: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 · 177 阅读 · 0 评论 -
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 · 178 阅读 · 0 评论 -
数论初步
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 · 167 阅读 · 0 评论 -
数论初步
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 · 167 阅读 · 0 评论 -
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 · 193 阅读 · 0 评论 -
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 · 232 阅读 · 0 评论 -
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 · 244 阅读 · 0 评论 -
身份证纹理去除思路探究
初步过滤经过研究观察模拟,发现身份证照片纹理是基于(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 · 2586 阅读 · 1 评论 -
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 · 579 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 242 阅读 · 0 评论 -
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 · 197 阅读 · 0 评论 -
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 · 900 阅读 · 0 评论 -
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 · 216 阅读 · 0 评论 -
POJ 3278
这题以前写过,很简单的BFS。就是可能不容易想到。还是那么一句话,最短路,BFS。AC比较轻松,算是BFS的练手题吧。#include <cstdio> #include <iostream> #include <queue> #include <cstring> using namespace std;#define maxn 100005 int n,k; queue<int> q; int s原创 2016-06-28 09:33:08 · 154 阅读 · 0 评论 -
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 · 190 阅读 · 0 评论 -
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 · 164 阅读 · 0 评论 -
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 · 418 阅读 · 0 评论 -
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 · 192 阅读 · 0 评论 -
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 · 123 阅读 · 0 评论 -
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 · 169 阅读 · 0 评论 -
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 · 319 阅读 · 0 评论 -
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 · 461 阅读 · 0 评论