自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 机器学习-----吴恩达课后习题ex5

偏差和方差 利用水库水位变化预测大坝出水量import numpy as npimport matplotlib.pyplot as pltfrom scipy.io import loadmatfrom scipy.optimize import minimizedata = loadmat('ex5data1.mat')data.keys()# dict_keys(['__header__', '__version__', '__globals__', 'X', '...

2021-08-18 18:10:59 417

原创 机器学习-----吴恩达课后习题ex4

BP-反向传播import numpy as npimport scipy.io as sioimport matplotlib.pyplot as pltfrom scipy.optimize import minimizedata = sio.loadmat('ex4data1.mat')raw_X = data['X']raw_y = data['y']X = np.insert(raw_X,0,values=1,axis=1) #输入层加偏值1.对y进行独热编码处理:on

2021-08-18 11:23:39 271

原创 机器学习-----吴恩达课后习题ex3

这个部分需要你实现手写数字(0到9)的识别。你需要扩展之前的逻辑回归,并将其应用于一对多的分类。ex3-神经网络-前向传播import numpy as npimport scipy.io as siodata = sio.loadmat('ex3data1.mat')raw_X = data['X']raw_y = data['y']X = np.insert(raw_X,0,values=1,axis=1)X.shape# (5000,401)y = ra...

2021-08-18 10:46:58 236

原创 机器学习-----吴恩达课后习题ex2

ex2-线性可分import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdata = pd.read_csv('ex2data1.txt',names=['Exam 1','Exam 2','Accepted'])data.head()fig,ax = plt.subplots()ax.scatter(data[data['Accepted']==0]['Exam 1'],data[data..

2021-08-17 20:58:54 277

原创 matplotlib个人总结

fig, ax = plt.subplots(figsize=(12,8))ax.plot(x, f, 'r', label='Prediction')ax.scatter(data.Population, data.Profit, label='Traning Data')ax.legend(loc=2)ax.set_xlabel('Population')ax.set_ylabel('Profit')ax.set_title('Predicted Profit vs. Population

2021-08-05 21:31:51 282

原创 Pandas个人总结

持续更新-------pd.read_csv()画出散点图data.plot(kind='scatter',x='Population',y='Profit',figsize=(12,8))data.ilocdata.shape

2021-08-05 21:31:37 115

原创 Numpy个人总结

np.power()x 和 y 为单个数字import numpy as npprint(np.power(2, 3))8x 为列表,y为数字print(np.power([2,3,4], 3))[ 8 27 64]x 为数字,y为列表print(np.power(2, [2,3,4]))[ 4 8 16]np.sum()import numpy as npa = np.array([[[1,2,3,2],[1,2,3,1],[2,3,4,..

2021-08-05 21:31:14 128

原创 机器学习-----吴恩达课后习题ex1

def computeCost(X,y,theta): inner = np.power(X @ theta-y,2) return np.sum(inner)/(2 * len(X))def gradientDescent(X, y, theta, alpha, iters): costs = [] for i in range(iters): theta = theta- (X.T @(X @theta-y))*alpha/len(X) ...

2021-08-05 20:34:12 646

原创 poj1149--PIGS (网络最大流,Ford-Fulkerson算法 和 dinic算法)

Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys...

2019-04-23 16:13:56 305

原创 uva-11987 Almost Union-Find (并查集)

题意: 初始给定n个集合:{1},{2},…,{n},要求支持三种操作: "1 p q":若p,q不在同一集合,将它们所在的集合合并成一个 "2 p q":若p,q不在同一集合,将元素p移动到q所在的集合 "3 p" :询问p所在集合的元素个数及元素和 总共m个操作,1<=n,m<=10^5分析:第一种操作直...

2019-04-22 16:39:34 206

原创 POJ 3255 Roadblocks --次短路 + spfa

Bessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery along the way. She...

2019-04-22 16:15:10 258

原创 hdu1711 Number Sequence 【kmp】

Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K ...

2019-04-11 09:51:49 230

原创 LightOJ 1024 - Eid (高精度乘法求n个数的LCM)

In a strange planet there arenraces. They are completely different as well as their food habits. Each race has a food-eating period. That means theithrace eats after everyxide-sec(de-sec is the...

2019-04-09 20:51:50 286

原创 LightOJ - 1007 Mathematically Hard (欧拉打表+前缀和)

Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable.In this problem, you will be given two integersaandb. You have to find the summatio...

2019-04-09 15:30:20 187

原创 hdu 2177-取(2堆)石子游戏(威佐夫博弈)

有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。如果你胜,你第1次怎样取子?Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含...

2019-04-09 15:19:59 523

原创 快速幂模板

#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int pow_mod(int a,int b){ int res=1; int ans=a; while(b) { if(b&1) ...

2019-04-03 20:47:16 139

原创 POJ 3070 Fibonacci [矩阵快速幂模板]

In the Fibonacci integer sequence,F0= 0,F1= 1, andFn=Fn− 1+Fn− 2forn≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alternati...

2019-04-03 19:54:06 150

原创 POJ - 2406 Power Strings

Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...

2018-12-09 20:31:57 155

原创 HDU - 1754 I Hate It 【点修改】

很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0&lt;N&lt;=200000,0&lt;M&lt;5000...

2018-12-09 08:44:29 156

原创 HDU - 1251 F - 统计难题

Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串. ...

2018-09-02 21:40:08 159

原创 LightOJ - 1234 I - Harmonic Number

In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer ...

2018-09-02 21:33:16 281

原创 LightOJ - 1245 G - Harmonic Number (II)

I was trying to solve problem '1234 - Harmonic Number', I wrote the following codelong long H( int n ) {    long long res = 0;    for( int i = 1; i &lt;= n; i++ )        res = res + n / i;    re...

2018-09-02 21:26:15 225

原创 LightOJ - 1138 N - Trailing Zeroes (III)

You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tr...

2018-09-02 21:14:00 589

原创 CodeForces - 645D A - Robot Rapping Results Report

While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition r...

2018-08-27 21:29:30 189

原创 UVA - 548 C - Tree

题意:输入一个二叉树的中序和后序,输出一个叶子节点,该叶子节点到根的数值总和最小。分析:先通过后序和中序建立二叉树,在通过DFS进行搜索,找到符合题目要求的叶子节点。中序和后序建立二叉树:使用递归来建立,由后序确定当前递归中的分支的根节点,再在中序中找到根的位置,则中序中根左的为左子树的中序排列,根右的为右子树的中序。设此时左子树的长度为len,则当前的后序的前len个数据是左子树的后序排列...

2018-08-27 18:57:02 351

原创 HDU - 1087 F - Super Jumping! Jumping! Jumping!

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game...

2018-08-27 17:42:21 197

原创 POJ - 2342 D - Anniversary party

There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a t...

2018-08-27 17:22:43 261

原创 HDU - 6375 F - 度度熊学队列

度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣。 初始时有 NN 个空的双端队列(编号为 11 到 NN ),你要支持度度熊的 QQ 次操作。 ①11 uu ww valval 在编号为 uu 的队列里加入一个权值为 valval 的元素。(w=0w=0 表示加在最前面,w=1w=1 表示加在最后面)。 ②22 uu ww 询问编号为 uu 的队列里的某个元素并删除它。( w=0...

2018-08-27 16:53:26 342

原创 UVA - 699 D - The Falling Leaves

题意:有一棵二叉树,每个节点都有一个水平位置,左子节点在它左边一个单位,右子节点在右边一个单位,从左向右输出每个水平位置的所有节点之和。分析:不用建树,可以直接遍历。用一个100的数组,正中间是根的位置,往左就减1,往右就加1,把落叶数加上去,模仿dfs,去遍历一遍,在把数组不是0的输出。代码:#include&lt;stdio.h&gt;#include&lt;string.h...

2018-08-27 16:37:29 257

原创 UVA - 839 B - Not so Mobile

题意:输入一个树状天平,根据力矩相等原则判断是否平衡(WlDl=WrDr),Wl和Wr分别为左右俩边砝码的重量,D为距离。Wl和Wr为0时,表示该砝码还有子天平,当Wl=Wr=0时,会先描述左子天平,然后右子天平。分析:  需要判断子天平平衡和判断父天平是否平衡。子天平可以根据公式判断 ,父天平的两边的重量是子天平砝码总和。  在进行先序遍历时,需要一个参数用来获取子天平的总质量。代码:...

2018-08-27 16:27:23 179

原创 HDU - 3999 E - The order of a Tree

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.  insert a key k to a empty tree, then the tree become a tree with only one node; ...

2018-08-27 16:08:42 261

原创 HDU - 3791 A - 二叉搜索树

判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1&lt;=n&lt;=20) 表示有n个需要判断,n= 0 的时候输入结束。 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。Output如果序列相同...

2018-08-27 15:42:20 438

原创 POJ - 2255 B - Tree Recovery

Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes. This is an example of one of her creat...

2018-08-19 21:39:22 211

原创 CodeForces 789C Functions again

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the ar...

2018-08-19 21:16:37 262

原创 CodeForces - 505B C - Mr. Kitayuta's Colorful Graph

Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex ...

2018-08-19 20:33:03 236

原创 51Nod - 1204 B - Parity

你的朋友写下一串包含1和0的串让你猜,你可以从中选择一个连续的子串(例如其中的第3到第5个数字)问他,该子串中包含了奇数个还是偶数个1,他会回答你的问题,然后你可以继续提问......你怀疑朋友的答案可能有错,或说同他之前的答案相互矛盾,例如:1 - 2 奇数,3 - 4 奇数,那么可以确定1 - 4 一定是偶数,如果你的朋友回答是奇数,就产生了矛盾。给出所有你朋友的答案,请你找出第一个出现矛盾...

2018-08-17 02:22:03 162

原创 POJ - 3522 B - Slim Span

Given an undirected weighted graph G, you should find one of spanning trees specified as follows.The graph G is an ordered pair (V, E), where V is a set of vertices {v1, v2, …, vn} and E is a set o...

2018-08-17 01:44:31 10421

原创 HDU - 1385 A - Minimum Transport Cost

These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transpo...

2018-08-16 21:07:21 220

原创 HDU - 2120 A - Ice_cream's world I

ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall between watchtowe...

2018-08-16 20:40:28 214

原创 POJ - 2502 J - Subway

You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you don't want...

2018-08-14 15:21:49 164

空空如也

空空如也

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

TA关注的人

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