one step

递归的一些问题实现及尾递归思考

大憨熊 提交于 2021-01-24 11:37:20
Part 1 什么是递归: 我们知道循环(iteration)和递归(recursion)可以理解为孪生兄弟,递归是函数抽象表达的一种。递归的优点显而易见,它在某些条件下,比循环代码量更少。递归简单来说,就是在运行过程中调用自己。而递归的实现需要满足两个条件,存在限制条件,在函数体同时在递归过程中不断逼近限制条件。(此阶段暂不考虑栈溢出) Part 2 一些递归的问题(任何理论逃不开实例): (1)汉诺塔问题: 首先我们要知道什么是汉诺塔问题: 这源于一个印度的传说,作者为避免文字误会,直接引用:“大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一个圆盘。” 简言之,现在有3个柱子,其中A柱有n个铁片从上至下为从小至大的顺序,B,C柱为空柱,需要利用B柱,将A柱上贴片转移到C柱,但是在过程中满足,大铁片不能出现在小铁片之上。 首先我们将n设置为3,观察移动过程: 借用知乎博主酱紫君gif 假设n=3的过程我们已经知道,此时我们来思考n=4时的过程 首先,我们将A上的前3个贴片移到B柱子上,则会出现下面的情景(过程一): 再将A上的最后一个贴片移到C柱上(过程2) 此时我们只需要将B柱子上的的三个贴片重复n

论文笔记:Diffusion-Convolutional Neural Networks (传播-卷积神经网络)

我是研究僧i 提交于 2020-11-21 02:37:25
Diffusion-Convolutional Neural Networks (传播-卷积神经网络) 2018-04-09 21:59:02 1. Abstract :   我们提出传播-卷积神经网络(DCNNs),一种处理 graph-structured data 的新模型。随着 DCNNs 的介绍,我们展示如何从 graph structured data 中学习基于传播的表示(diffusion-based representations),然后作为节点分类的有效基础。DCNNs 拥有多个有趣的性质,包括:   1). a latent representation for graphical data that is invariant under isomorphism;   2). polynomial-time prediction;   3). learning that can be represented as tensor operations;   4). efficiently implemented on a GPU. 2. Introduction :   处理结构化的数据是非常有挑战的。一方面,找到合适的方法来展示和探索数据的结构可以获得预测精度的提升;另一方面,找到这样的结构可能很困难,在模型中添加结构会使得预测复杂度显著的提升。  

强化学习七

随声附和 提交于 2020-10-29 06:57:09
一.前言   之前我们讨论的所有问题都是先学习action value,再根据action value 来选择action(无论是根据greedy policy选择使得action value 最大的action,还是根据ε-greedy policy以1-ε的概率选择使得action value 最大的action,action 的选择都离不开action value 的计算)。即 没有action value的估计值就无法进行action选择,也就没有Policy,这类方法被称为 value-based methods. 其实我们可以直接产生不依赖于action value 的polcy ,这类直接生成action的方法就叫policy-based methods.他们关系如下:   value-based方法,需要计算价值函数(value function),根据自己认为的高价值选择行(action)的方法,如Q Learning。   policy-based方法,不需要根据value function选择action,可以直接得出policy的方法。   图中第三类方法(Actor critic)结合了上述两者, 即计算value function,但不直接根据value function选择action,action 由policy-based方法得到。 二.

HDU 6312 GAME

泪湿孤枕 提交于 2020-10-28 10:29:21
Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 393 Accepted Submission(s): 283 Problem Description Alice and Bob are playing a game. The game is played on a set of positive integers from 1 to n. In one step, the player can choose a positive integer from the set, and erase all of its divisors from the set. If a divisor doesn't exist it will be ignored. Alice and Bob choose in turn, the one who cannot choose (current set is empty) loses. Alice goes first, she wanna know whether she can win. Please judge by outputing 'Yes' or 'No'. Input

如何在Linux中一步更改文件夹及其所有子文件夹和文件的权限? [关闭]

南笙酒味 提交于 2020-10-20 13:11:27
问题: I would like to change permissions of a folder and all its sub folders and files in one step (command) in Linux. 我想在Linux中一步(命令)更改文件夹及其所有子文件夹和文件的权限。 I have already tried the below command but it works only for the mentioned folder: 我已经尝试过以下命令,但它仅适用于上述文件夹: chmod 775 /opt/lampp/htdocs Is there a way to set chmod 755 for /opt/lampp/htdocs and all of its content including subfolders and files? 有没有办法为 /opt/lampp/htdocs 设置 chmod 755 及其所有内容,包括子文件夹和文件? Also, in the future, if I create a new folder or file inside htdocs , how can the permissions of that automatically be set to 755 ? 此外,将来,如果我在

codeforces 876 D. Sorting the Coins

China☆狼群 提交于 2020-08-08 18:59:38
http://codeforces.com/contest/876/problem/D D. Sorting the Coins time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row in such a way that firstly come coins out of circulation, and then come coins still in circulation. For arranging coins Dima uses the following algorithm. One step of his

IJCAI 2020 小样本、零样本、领域自适应、元学习论文汇总

风流意气都作罢 提交于 2020-08-05 09:16:57
小样本学习(few-shot learning) SimPropNet: Improved Similarity Propagation for Few-shot Image Segmentation Learning Task-aware Local Representations for Few-shot Learning Transductive Relation-Propagation Network for Few-shot Learning Few-shot Visual Learning with Contextual Memory and Fine-grained Calibration Few-shot Human Motion Prediction via Learning Novel Motion Dynamics Weakly Supervised Few-shot Object Segmentation using Co-Attention with Visual and Semantic Embeddings Self-Supervised Tuning for Few-Shot Segmentation Multi-attention Meta Learning for Few-shot Fine-grained Image Recognition

27. Remove Element

别说谁变了你拦得住时间么 提交于 2020-07-24 13:05:31
27. Remove Element Given an array nums and a value val , remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond the new length. Example 1: Given nums = [0,1,2,2,3,0,4,2] , val = 2 , Your function should return length= 5 , with the first five elements of nums containing 0, 1, 3, 0 and 4. Note that the order of those five elements can be arbitrary. It doesn't matter what values

[LeetCode] 583. Delete Operation for Two Strings 两个字符串的删除操作

大憨熊 提交于 2020-05-04 06:36:26
Given two words word1 and word2 , find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string. Example 1: Input: "sea", "eat" Output: 2 Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea". Note: The length of given words won't exceed 500. Characters in given words can only be lower-case letters. 求出最长相同子序列Longest Common Subsequence,然后两个单词长度和减去2倍的相同子序列长度就是答案。 解法1: 递归, 如果[0, i], [0, j]最后一个字符相同,则比较[0, i-1], [0, j-1]的最后一个字符,若不相同,则删去第i个或第j个字符后,返回长度更长的子序列。TLE 解法2:动态规划dp,dp[i][j

Plants vs. Zombies(2018ICPC青岛站E题) 二分

怎甘沉沦 提交于 2020-05-04 06:13:32
Plants vs. Zombies                                                ZOJ - 4062 BaoBao and DreamGrid are playing the game Plants vs. Zombies . In the game, DreamGrid grows plants to defend his garden against BaoBao's zombies There are plants in DreamGrid's garden arranged in a line. From west to east, the plants are numbered from 1 to and the -th plant lies meters to the east of DreamGrid's house. The -th plant has a defense value of and a growth speed of . Initially, for all . DreamGrid uses a robot to water the plants. The robot is in his house initially. In one step of watering, DreamGrid will