mac平台配置anaconda 1.下载:清华大学镜像 2.安装:傻瓜式 安装位置:Mactonish HD 3.配置镜像源:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.c...
一篇文章弄懂string和cstring的相互转化,以及字符串到数值的转化 cstring就是char数组,string是stl中定义的数据结构,二者可以相互转化,另外我们经常需要从字符串中提取出数字,下面一一介绍。cstring -> stringcstring的历史早于string,所以它cstring本身当然不会有方法可以直接转化为string,但是string却可以用cstring来初始化或者调用构造函数string str(cstr)...
3470 整理扑克牌 题目链接思路1.简单模拟+贪心,每次选择数目最少的牌,用特俗牌替代它,组合成一副牌,直到特殊牌数目为0,然后可以再组合出所剩最少数目副牌。#include<iostream>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#includ...
bailian 1308 Is it a tree 题目链接题目中并没有保证节点编号是1~n连续的,所以可以用map做一个映射。 如何判断一个有向图是树呢? 树有很多等价定义,如何方便判断呢? 可以利用bfs,进行判断:先找到一个入度为0的点,从这个点开始bfs,如果找不到说明存在环,但是需要注意的是,如果顶点个数为0,按照题意也是树。这种情况,可以最后排除。一般情况下,节点数为1,且没有自环,也应该是树,但这一题是通过边给出图的,也就是...
int溢出 uva10006 快速幂乘法,虽然每一步乘法后都取余,但是仍然可能溢出#include<cstdio>#include<cmath>using namespace std;int expmod(int _a,int n,int mod){ long long a=_a,ans=1; while(n){ if(n%2){ans*...
gets的坑 当gets第一个遇到的字符是换行符时,就不往下读了,只能读到一个空串,为了读取下一个字符串,其实我们需要的应该是scanf("%s",s) 题目#include<cstdio>using namespace std;struct node{ node *lc,*rc; int e;} nodes[110];int cur=0;node * newn...
从两道题看如何读取字符串 二次方程#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<stack>#include<cmath>using namespace std;int cba[3],epos;char str[100]...
简单表达式计算 表达式要求:只包含加减乘除和整数运算数,且运算符与操作数直接有一个空格隔开#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<stack>using namespace std;int mat[5][5]={ ...
字符常量默认类型的坑 做poj 2155时,需要计算 2^k,自然想到用位运算:1<<k,但却WA,因为我用的是long long ,#include<cstdio>using namespace std;typedef long long ll;ll exgcd(ll a,ll b,ll &x,ll& y){ if(b==0) { x=1;y=0; ret...
poj 1270拓扑排序 poj 1270#include<cstdio>#include<queue>#include<cstring>#include<algorithm>char s[150];int sufix[30][30],ind[30], topo[30];int n=0;void print(){ for(int i=0;i<...
pytorch学习教程:Variable torch.autograd.Variable,从定义的位置就可以知道,Variable是为了自动求导的。 其实Variable只是把Tensor封装了一下,增加了新的功能,所以很多可以作用于Tensor的函数可以直接作用于Variable上。 注意:下文中所有a代表一个Tensor生成一个VariableVariable(a,requires_grad=False)即可得到一个...
Pytorch学习教程:Tensor Tensor对于pytorch就如同ndarray,而且和ndarray很像,但有一个重要的区别就是Tensor支持GPU,ndarray不支持。注意为了说明方便, 1.Tensor分类: ByteTensor,唯一的一个无符号类型Tensor,8位无符号整型(下面皆有符号) CharTensor,8位有符号整型 ShortTensor,16位整型 IntTensor,32位整型...
Pytorch学习教程:学习资源 几个网站 1.官方文档http://pytorch.org/docs/master/ 2.论坛https://discuss.pytorch.org 3.中文文档http://pytorch-cn.readthedocs.io/zh/latest/ 4.pytorch中文网https://ptorch.com几本书 深度学习之Pytorch by廖星宇...
Pytorch学习教程:环境配置 笔者所用环境为Mac OSX,仅讨论该环境,Linux完全类似。 1.安装Anaconda,自行百度。 2.利用Anaconda,定义一个环境,用于Pytorch开发conda create -n yourenvname3.进入该环境source activate yourenvname4.利用pip安装相关包(需进入之前create的env中)sudo pip i...
计算24点 #include<cstdio>#include<cstring>#include<iostream>using namespace std;int vis[4];double num[4];const double delta=1e-5;bool zero(double x){ return x>-delta&&x&...
c++的输入不能隐式转换 #include<cstdio>#include<cstring>#include<iostream>using namespace std;int main(){ double x; scanf("%d",&x); cout<<x<<endl; return 0;}input &
poj 百练2818 #include<cstdio>#include<cstring>#include<iostream>using namespace std;int key[210],T[210];char Old[210],New[210];int main(){ int n; Old[205]='\0';New[205]='\0'; w...
poj 百练2800 垂直直方图 这一道题的输入输入输出很有特点,我的输入部分略显复杂,但是这样会更加鲁棒。 主要考虑到不同平台下换行符可能不一样,有的是,有的是\r,有的是\r,输入文件不一定有EOF#include<cstdio>#include<iostream>#include<cmath>#include<cstring>using namesp...
poj 百练校门外的树 题目很简单,但是一个小错误#include<cstdio>#include<iostream>#include<cmath>#include<cstring>using namespace std;int vis[10010];int main(){ int L,M; memset(vis,0,sizeof(vis...
poj bailian 1017装箱问题 没有对比,没有伤害!我的代码 思路是贪心的思想,从大往小装,将盒子中剩余的空间,装小的。 每新增加一个盒子,就从大往小遍历一遍,尽可能装。#include<cstdio>#include<iostream>#include<cmath>#include<cstring>using namespace std;int cnt[...