- 博客(37)
- 资源 (2)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Tensorflow环境下 线性回归(梯度下降)的练手实例(完整源码+说明)
Tensorflow 入门篇-最小二乘法的线性回归算法 本文将借助Tensorflow来实现最小二乘法的线性回归算法。 大体的思路:首先生成随机紊乱的数据集,然后构建线性回归的Graph,最后在Session中迭代train器,得到拟合的参数w和b,最后画出拟合曲线。最终结果如下图所示:1.首先导入三个库import numpy as npimport tensorflow as t...
2018-06-22 22:21:03
674
原创 Children's Game UVA - 10905 (简单贪心)
There are lots of number games for children. These games are pretty easy to play but not so easy tomake. We will discuss about an interesting game here. Each player will be givenNpositive integ...
2018-10-31 22:47:23
196
原创 HDU 4778 Gems Fight!(博弈+状压DP)
Problem Description Alice and Bob are playing "Gems Fight!": There are Gems of G different colors , packed in B bags. Each bag has several Gems. G different colors are numbered from color 1 t...
2018-10-25 20:10:25
159
原创 DFS序两道模板题+个人理解 10.17倒计时
DFS序可用于解决一些树上单点修改与查询问题这样就可以在线处理,无需每一次修改跑一遍最短路或是其他带n的算法在树中,遇到单点修改和查询的问题,可以考虑dfs+线段树or树状数组维护。Dfs抽象来说就是将一棵树由树状结构转化为线性结构,一个点到它的所有子树节点占据连续的位置。利用一遍的dfs记录每个点的起始位置(in数组)和结束位置(out数组),点的先后并不取决于存储方式,不变的是每个...
2018-10-17 22:44:42
293
原创 HDU 6390 多校第7场E题 数论+莫比乌斯反演+逆元
题意:给出函数,求值,取模推导过程:细节详见代码。#include <iostream>#include <string>#include <algorithm>#include <cstdio>#include <queue>#include <cstring>#include ...
2018-08-25 03:11:04
202
原创 POJ-1511 Invitation Cards (spfa | Dijkstar最小堆 多重境界优化)
题意:共有n个站点,为了宣传效果,每个站点必须有一个人(初始点站不站其实一样),给出m条单向路径和行走该段路径的费用cost,计算所有人来回车费的最小值。思路:计算一遍从源点出发到所有点的最短路径,相加。再反向计算一遍所有点到源点的最短路径,全部相加显然就是答案。但需注意,1<=n,m<=1000000,百万的数量级如果不优化,直接使用Dijkstar(n^2),会TLE,作者...
2018-08-06 02:07:46
418
原创 CodeForces - 8C Looking for Order (两种方法的实现:状压DP,DFS)
Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag...
2018-06-30 00:17:59
379
原创 Prince and Princess UVA - 10635(动态规划专题 LIS+Hash )
求两个数字串的最长公共子列,但是要注意,这里的n高达250^2=62500,LCS的复杂度为N^2,明显会超时。因为每个数字不重复,故可以建立从A到B的映射(若未在A中出现过,则记为0),将问题转化为LIS,即求B的最长上升子串,复杂度为N*log(N)。Code:#include<cstdio>#include<cstring>#include<cmath>...
2018-06-06 02:42:23
178
原创 HDU - 1078 FatMouse and Cheese (DP+记忆化搜索)
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid ...
2018-06-05 23:15:52
152
原创 POJ 1321 棋盘问题(DFS 简单搜索题)
在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格...
2018-05-27 22:55:21
190
原创 CodeForces - 364B Free Market (Dp+贪心思想结合 )
John Doe has recently found a "Free Market" in his city — that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (ea...
2018-05-27 22:00:24
240
原创 HDU-1069 Monkey and Banana [DP -> 二维最长上升串]
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...
2018-04-29 04:10:03
131
原创 51Nod 1013 3的幂的和 经典模板题+思路详细讲解【等比数列+快速幂+逆元】
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 <= N <= 10^9)Output输出:计算结果Input示例3Output示例40 题目大意&&解题思路:根据题目描述,即求一个a1为1,q为3的等比数列之和,公式为a1(1-q^n)/1-q ——>> (3^n-1)/2。这里有两个点需要思考...
2018-04-27 21:23:08
177
原创 Intervals ZOJ - 3953(贪心就完事了)【浙大17th校赛】
Chiaki has n intervals and the i-th of them is [li, ri]. She wants to delete some intervals so that there does not exist three intervals a, b and c such that a intersects with b, b intersects with c a...
2018-04-15 20:40:55
179
原创 Partitioning by Palindromes UVA - 11584(最小回文串分解DP)
We say a sequence of charactersis a palindrome if itis the same written forwardsand backwards. For example,‘racecar’ is a palindrome, but‘fastcar’ is not. A partition of a sequence ofcharacters...
2018-04-15 01:14:07
165
原创 POJ 1777 Picture(线段树+离散化+扫描线)
A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered b...
2018-04-13 00:19:41
256
原创 HDU-1556 Color the ball(线段树-区间染色)
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(...
2018-04-11 00:25:57
501
原创 Common Subsequence (LCS最大公共串模版题)POJ - 1458
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...
2018-04-06 14:55:28
187
原创 Brute Force Sorting (数组实现双向链表 经典模版)ACM-ICPC 青岛站
Beerus needs to sort an array of NN integers. Algorithms are not Beerus's strength. Destruction is what he excels. He can destroy all unsorted numbers in the array simultaneously. A number A[i]A[i] of...
2018-04-06 14:45:02
336
原创 Alphacode (动态规划思想)POJ - 2033 HDU - 1508
Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages: Alice: "Let's just use a very simple code: We'll assign 'A' the c...
2018-04-02 23:36:53
516
原创 L2-3 家庭房产(25 分)
给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。输入格式:输入第一行给出一个正整数N(≤),随后N行,每行按下列格式给出一个人的房产:编号 父 母 k 孩子1 ... 孩子k 房产套数 总面积其中编号是每个人独有的一个4位数的编号;父和母分别是该编号对应的这个人的父母的编号(如果已经过世,则显示-1);k(0k≤)是该人的子女的个数;孩子i是其子女的编...
2018-03-25 23:20:04
1658
原创 L1-4 情人节(15 分)
以上是朋友圈中一奇葩贴:“2月14情人节了,我决定造福大家。第2个赞和第14个赞的,我介绍你俩认识…………咱三吃饭…你俩请…”。现给出此贴下点赞的朋友名单,请你找出那两位要请客的倒霉蛋。输入格式:输入按照点赞的先后顺序给出不知道多少个点赞的人名,每个人名占一行,为不超过10个英文字母的非空单词,以回车结束。一个英文句点.标志输入的结束,这个符号不算在点赞名单里。输出格式:根据点赞情况在一行中输出结...
2018-03-25 23:07:20
1721
原创 L1-2 大笨钟(10 分)
微博上有个自称“大笨钟V”的家伙,每天敲钟催促码农们爱惜身体早点睡觉。不过由于笨钟自己作息也不是很规律,所以敲钟并不定时。一般敲钟的点数是根据敲钟时间而定的,如果正好在某个整点敲,那么“当”数就等于那个整点数;如果过了整点,就敲下一个整点数。另外,虽然一天有24小时,钟却是只在后半天敲1~12下。例如在23:00敲钟,就是“当当当当当当当当当当当”,而到了23:01就会是“当当当当当当当当当当当当...
2018-03-25 22:33:16
444
原创 L1-1 古风排版(20 分)
中国的古人写文字,是从右向左竖向排版的。本题就请你编写程序,把一段文字按古风排版。输入格式:输入在第一行给出一个正整数N(<),是每一列的字符数。第二行给出一个长度不超过1000的非空字符串,以回车结束。输出格式:按古风格式排版给定的字符串,每列N个字符(除了最后一列可能不足N个)。输入样例:4This is a test case输出样例:asa Tst ihe tsi ce s...
2018-03-25 22:29:19
861
原创 Uva 839 天平问题(模板题)
Before being an ubiquous communications gadget, a mobilewas just a structure made of strings and wires suspendingcolourfull things. This kind of mobile is usually found hangingover cradles of small ba...
2018-03-24 00:26:36
332
原创 HDU 4528 小明系列故事——捉迷藏 bfs
小明的妈妈生了三个孩子,老大叫大明, 老二叫二明, 老三..., 老三自然就叫小明了。 一天,小明的妈妈带小明兄弟三人去公园玩耍,公园里面树木很多,有很多地方可以藏身, 于是他们决定玩捉迷藏。经过几轮的猜拳后,第一轮是小明来找其他两个人,游戏规则很简单: 只要小明可以在规定的时间内找到他们就算小明获胜,并且被发现的两个人猜拳决定谁在下一轮负责找人;如果在规定的时间内只找到一个人,那么没有被...
2018-02-23 12:22:26
408
原创 HDU 1016 && Uva 524 Prime Ring Problem(素数环)
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number of f...
2018-02-14 01:15:28
250
原创 Uva 725 Division (暴力搜索求解,入门题)
Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided by the second is equal to an integer N, ...
2018-02-12 22:23:20
244
原创 Uva 514 Rails (STL 栈+队列 模拟)
There is a famous railway station in PopPush City. Country there is incredibly hilly. The stationwas built in last century. Unfortunately, funds were extremely limited that time. It was possible toest...
2018-02-08 12:59:03
241
原创 ACM/ICPC World Finals 1990 && UVA 201 Squares(数正方形)
A children’s board game consists of a square array of dots that contains lines connecting some of the pairs of adjacent dots. One part of the game requires that the players count the number of square
2018-02-05 05:54:39
497
原创 ACM/ICPC Fuzhou 2011 && HDU 4121 下象棋 (超详细思路 全局判断)
Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of capturing the enemy’s “general” piece. In this problem, you are giv
2018-02-05 03:21:32
454
1
原创 HDU - 1232、1863 畅通工程 (初识并查集)
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路...
2018-02-03 01:37:05
135
原创 CodeForces - 576A Vasya and Petya's Game 质数筛选
Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.Petya can ask questions like: "Is the unknown number divisible by number y?"
2018-02-01 05:44:57
315
原创 HDU - 1242 Rescue(迷宫问题 深搜 )
Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to sa
2018-01-31 02:12:04
318
原创 OpenJ_Bailian - 3752 走迷宫 (水题:深搜&&广搜 比较)
一个迷宫由R行C列格子组成,有的格子里有障碍物,不能走;有的格子是空地,可以走。 给定一个迷宫,求从左上角走到右下角最少需要走多少步(数据保证一定能走到)。只能在水平方向或垂直方向走,不能斜着走。 Input 第一行是两个整数,R和C,代表迷宫的长和宽。( 1接下来是R行,每行C个字符,代表整个迷宫。 空地格子用'.'表示,有障碍物的格子用'#'表示。 迷宫左上角和右下角都
2018-01-31 01:16:07
920
原创 POJ-2182 Lost Cows 新思路
N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. Wh
2018-01-29 03:19:56
159
原创 POJ-2632 Crashing Robots (碰撞的机器人)
In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure that the robots reach their destinations without crashing into each other. Of course, all warehouses
2018-01-29 03:14:09
256
多种群遗传算法函数优化
2018-03-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人