num

STL练习-排列2

痞子三分冷 提交于 2020-02-14 11:13:39
Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数。 Input 每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如果四张卡片都是0,则输入结束。 Output 对每组卡片按从小到大的顺序输出所有能由这四张卡片组成的4位数,千位数字相同的在同一行,同一行中每个四位数间用空格分隔。每组输出数据间空一行,最后一组数据后面没有空行。 Sample Input 1 2 3 4 1 1 2 3 0 1 2 3 0 0 0 0 Sample Output 1234 1243 1324 1342 1423 1432 2134 2143 2314 2341 2413 2431 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321 1123 1132 1213 1231 1312 1321 2113 2131 2311 3112 3121 3211 1023 1032 1203 1230 1302 1320 2013 2031 2103 2130 2301 2310 3012 3021 3102 3120 3201 3210 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4

线性回归

十年热恋 提交于 2020-02-14 11:07:41
线性回归 主要内容包括: 线性回归的基本要素 线性回归模型从零开始的实现 线性回归模型使用pytorch的简洁实现 线性回归的基本要素 模型 为了简单起见,这里我们假设价格只取决于房屋状况的两个因素,即面积(平方米)和房龄(年)。接下来我们希望探索价格与这两个因素的具体关系。线性回归假设输出与各个输入之间是线性关系: \[ \mathrm{price} = w_{\mathrm{area}} \cdot \mathrm{area} + w_{\mathrm{age}} \cdot \mathrm{age} + b \] 数据集 我们通常收集一系列的真实数据,例如多栋房屋的真实售出价格和它们对应的面积和房龄。我们希望在这个数据上面寻找模型参数来使模型的预测价格与真实价格的误差最小。在机器学习术语里,该数据集被称为训练数据集(training data set)或训练集(training set),一栋房屋被称为一个样本(sample),其真实售出价格叫作标签(label),用来预测标签的两个因素叫作特征(feature)。特征用来表征样本的特点。 损失函数 在模型训练中,我们需要衡量价格预测值与真实值之间的误差。通常我们会选取一个非负数作为误差,且数值越小表示误差越小。一个常用的选择是平方函数。 它在评估索引为 \(i\) 的样本误差的表达式为 \[ l^{(i)}(\mathbf

最大子序列和(Max Sum ,Super Jumping! Jumping! Jumping! )

本小妞迷上赌 提交于 2020-02-14 08:45:07
连续的子序列: Max Sum Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000). Output For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three

JAVA测验—学生学籍管理系统

核能气质少年 提交于 2020-02-14 03:36:28
设计思路: 创建基本的ScoreInfoemation类,创建基本的数据成员以及基本的设置方法、获取数据方法以及有无参的构造方法。 1 package Test; 2 3 import java.util.*; 4 5 public class ScoreInformation { 6 7 private String stunumber; 8 private String name; 9 private double mathematicsscore; 10 private double englishisscore; 11 private double networkscore; 12 private double databasescore; 13 private double softwarescore; 14 public void setStunumber(String stu) 15 { 16 this.stunumber=stu; 17 } 18 String getStunumber() 19 { 20 return this.stunumber; 21 } 22 void setName(String name) 23 { 24 this.name=name; 25 } 26 String getName() 27 { 28 return this.name;

codeforces-1163 (div2)

落花浮王杯 提交于 2020-02-14 00:26:27
想开div3开成div2了,比赛的时候还以为我又菜了。 赛后经验:关爱视力 从我做起 A.删除第一个点的时候断环成链,不产生贡献,后面每隔一个拆一个点都会让联通块最终答案 + 1 没有可以产生贡献的点的时候就需要删联通块,此时产生反向贡献答案 - 1 #include <map> #include <set> #include <ctime> #include <cmath> #include <queue> #include <stack> #include <vector> #include <string> #include <cstdio> #include <cstdlib> #include <cstring> #include <sstream> #include <iostream> #include <algorithm> #include <functional> using namespace std; #define For(i, x, y) for(int i=x;i<=y;i++) #define _For(i, x, y) for(int i=x;i>=y;i--) #define Mem(f, x) memset(f,x,sizeof(f)) #define Sca(x) scanf("%d", &x) #define Sca2(x,y) scanf

动手学深度学习:task01

北慕城南 提交于 2020-02-14 00:23:54
task01-线性模型、softmax与分类模型、多层感知机 一. 线性回归模型从零开始的实现 0.准备工作 #导入可视化的包和基本包 % matplotlib inline import torch from IPython import display from matplotlib import pyplot as plt import numpy as np import random print ( torch . __version__ ) 1.生成数据集 使用线性模型来生成数据集,生成一个1000个样本的数据集,线性关系: price = w1⋅area + w2⋅age + b # 输入特征 num_inputs = 2 # 样本数 num_examples = 1000 # 权重 偏差 true_w = [ 2 , - 3.4 ] true_b = 4.2 features = torch . randn ( num_examples , num_inputs , dtype = torch . float32 ) # 线性关系表达式 labels = true_w [ 0 ] * features [ : , 0 ] + true_w [ 1 ] * features [ : , 1 ] + true_b labels += torch . tensor (

Python十个实例(二)

风流意气都作罢 提交于 2020-02-14 00:19:10
0x00 判断奇偶 while True: try: num = int(input("请输入一个整数:")) except ValueError: print("输入的不是整数!") continue if num%2 == 0: print("这是一个偶数!") else: print("这是一个奇数!") break 0x01 判断闰年 year = int(input("请输入一个年份:")) if (year % 4) == 0 and (year % 100) != 0 or (year % 400) == 0: print("%d是闰年" % year) else: print("%d不是闰年" % year) 0x02 比较大小 while True: try: N = int(input("请输入需要比较的数字个数:")) print("请输入需要对比的数字:") num = [] for i in range(1,N+1): temp = int(input("输入第%d个数字:" % i)) num.append(temp) print("您输入的数字为:", num) print("最大值为:", max(num)) break except ValueError: print("输入有误!") 0x03 判断质数 while True: try: num

MySQL(一)--基本语法与常用语句

两盒软妹~` 提交于 2020-02-13 23:58:38
将大量数据保存起来,通过计算机加工而成的可以进行高效访问的数据集合称为数据库(Database,DB)。 将姓名、住址、电话号码、邮箱地址、爱好和家庭构成等数据保存到数据库中,就可以随时迅速获取想要的信息了。用来管理数据库的计算机系统称为数据库管理系统(Database Management System,DBMS)。 DBMS有过数据的保存格式(数据库的种类)来进行分类,现阶段主要有五种类型:层次数据库(Hierarchical Database,HDB),关系数据库(Relational Database,RDB),面向对象数据库(Object Oriented Database,OODB),XML 数据库(XML Database,XMLDB),键值存储系统(Key-Value Store,KVS)。 DBMS 称为关系数据库管理系统(Relational Database Management System,RDBMS)。比较具有代表性的 RDBMS 有 Oracle Database :甲骨文公司;SQL Server :微软公司;DB2 :IBM 公司;PostgreSQL :开源;MySQL :开源。 MySQL作为很好的 RDBMS 应用软件之一,使用率也是upup的。因为懒,文中操作仅在MySQL5.7上加以验证。 零、准备 1、安装MySQL 2、服务端启动 3

LeetCode.1103-向人们分发糖果(Distribute Candies to People)

旧时模样 提交于 2020-02-13 23:27:03
这是小川的第 393 次更新,第 425 篇原创 01 看题和准备 今天介绍的是 LeetCode 算法题中 Easy 级别的第 256 题(顺位题号是 1103 )。我们通过以下方式向一排 n = num_people 个人分发一些糖果: 给第一个人送1个糖果,给第二个人送2个糖果,依此类推,直到我们给最后一个人送糖果。然后,我们回到行的开头,向第一个人提供 n + 1 个糖果,向第二个人提供 n + 2 个糖果,依此类推,直到我们向最后一个人提供 2 * n 个糖果。 这个过程重复进行,直到我们用完糖果。最后一个人将得到所有剩余的糖果(不一定比之前收到的多)。 返回一个数组(长度为 num_people ,元素总和为 candies ),代表糖果的最终分配结果。 例如: 输入:candies = 7,num_people = 4 输出:[1,2,3,1] 说明: 第一次,ans [0] + = 1,数组为[1,0,0,0]。 第二次,ans [1] + = 2,数组是[1,2,0,0]。 第三次,ans [2] + = 3,数组是[1,2,3,0]。 第四次,ans [3] + = 1(因为只剩下一个糖果)。 最后数组是[1,2,3,1]。 输入:candies = 10,num_people = 3 输出:[5,2,3] 说明: 第一次,ans [0] + = 1,数组为[1

运用NP求解 “跳跃游戏”---计蒜客

旧时模样 提交于 2020-02-13 22:40:34
计蒜客里面有一道“跳跃游戏的问题” 给定一个非负整数数组,假定你的初始位置为数组第一个下标。 数组中的每个元素代表你在那个位置能够跳跃的最大长度。 你的目标是到达最后一个下标,并且使用最少的跳跃次数。 例如: A = [2,3,1,1,4] ,到达最后一个下标的最少跳跃次数为 2 。(先跳跃 1 步,从下标 0 到 1 ,然后跳跃 3 步,到达最后一个下标。一共两次) 输入格式 第一行输入一个正整数 n ,接下来的一行,输入 n 个整数,表示数组 A。 输出格式 最后输出最少的跳跃次数。 这道题目吧,其实理解了动态规划算法的思路也就不是那么困难了。而大家都知道,动态规划问题就是说将大问题细化成小问题,而小问题的结果已经在之前的递归中被保存到数组里,也就是说大问题的求解可以直接拿小问题的结果来用。 对于这个跳跃问题,我们可以将思想分为三个部分。 第一: int num ; cin>>num; int intt[101]; intt[0]=-1; for(int i=1;i<=num;i++){ cin>>intt[i]; array[i] = 99999; } 在这部分代码中,我们是定义了一个intt[]数组来保存输入的num个数,并且array[i]的作用就是用来保存跳到intt[i] 这个数的最优解。在开始的时候,我们复制给array[i]一个很大的数(给定一个大的初值