自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 牛客网[编程题]--彩色的砖块

题目描述小易有一些彩色的砖块。每种颜色由一个大写字母表示。各个颜色砖块看起来都完全一样。现在有一个给定的字符串s,s中每个字符代表小易的某个砖块的颜色。小易想把他所有的砖块排成一行。如果最多存在一对不同颜色的相邻砖块,那么这行砖块就很漂亮的。请你帮助小易计算有多少种方式将他所有砖块排成漂亮的一行。(如果两种方式所对应的砖块颜色序列是相同的,那么认为这两种方式是一样的。)例如: s = "AB...

2019-02-23 15:10:59 282

原创 C++——二维vector初始化

1、定义时初始化vector<vector<int> > v(n, vector<int>(m, num)); //n行m列,初始化数值numvector<vector<int> > v(0, vector<int> (0)); //不确定行列数vector<vector<int&am

2019-02-22 21:22:18 2381

原创 ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

问题:在训练模型 fit(x_train,y_train) 时遇到报错 ValueError: Input contains NaN, infinity or a value too large for dtype('float64')  解决方法:1、检查数据中是否有缺失值,并做缺失值处理# 读取数据train = pd.read_csv('./data/train....

2019-02-22 15:07:29 73377 8

原创 数据结构基本概念

1、数据结构基本概念数据(data):对客观事物的符号表示,能输入到计算机中并被计算机程序处理的符号的总称。例如正数,字符串,图像,音频等。 数据元素(data element):数据的基本单位。 数据项(data item):数据不可分割的最小单位,一个数据元素可由多个数据项组成。 数据对象(data object):性质相同的数据元素的集合,是数据的一个子集。例如整数集合。 数据结...

2019-02-21 19:43:43 846

原创 PAT (Advanced Level) Practice 1076 Forwards on Weibo (30 分)

编程题1076 Forwards on Weibo (30 分)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is forme...

2018-11-16 00:16:31 141

原创 PAT (Advanced Level) Practice 1013 Battle Over Cities (25 分)

编程题1013 Battle Over Cities (25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed...

2018-11-14 23:33:55 157

原创 PAT (Advanced Level) Practice 1072 Gas Station (30 分)

编程题1072 Gas Station (30 分)A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it mu...

2018-11-14 21:03:16 151

原创 PAT (Advanced Level) Practice 1034 Head of a Gang (30 分)

编程题1034 Head of a Gang (30 分)One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight ...

2018-11-13 23:41:31 134

原创 PAT (Advanced Level) Practice 1021 Deepest Root (25 分)

编程题1021 Deepest Root (25 分)A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on the selected root. Now you are supposed to find the root that results in...

2018-11-12 19:16:08 134

原创 PAT (Advanced Level) Practice 1119 Pre- and Post-order Traversals (30 分)

编程题1119 Pre- and Post-order Traversals (30 分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inord...

2018-11-09 11:07:53 127

原创 PAT (Advanced Level) Practice 1115 Counting Nodes in a BST (30 分)

编程题1115 Counting Nodes in a BST (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with key...

2018-11-09 11:01:09 116

原创 PAT (Advanced Level) Practice 1106 Lowest Price in Supply Chain (25 分)

  编程题1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer....

2018-11-09 10:57:28 174

原创 PAT (Advanced Level) Practice 1102 Invert a Binary Tree (25 分)

编程题1102 Invert a Binary Tree (25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboar...

2018-11-09 10:27:59 149

原创 PAT (Advanced Level) Practice 1094 The Largest Generation (25 分)

编程题1094 The Largest Generation (25 分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generat...

2018-11-09 10:21:55 110

原创 PAT (Advanced Level) Practice 1090 Highest Price in Supply Chain (25 分)

编程题1090 Highest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer....

2018-11-09 10:04:23 109

原创 PAT (Advanced Level) Practice 1086 Tree Traversals Again (25 分)

编程题1086 Tree Traversals Again (25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbe...

2018-11-09 09:53:15 96

原创 PAT (Advanced Level) Practice 1079 Total Sales of Supply Chain (25 分)

编程题1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.St...

2018-11-09 09:48:29 136

原创 PAT (Advanced Level) Practice 1053 Path of Equal Weight (30 分)

编程题1053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight W​i​​ assigned to each tree node T​i​​. The weight of a path from R to L is defined to be the sum of the weigh...

2018-11-04 23:29:31 139

原创 PAT (Advanced Level) Practice 1020 Tree Traversals (25 分)

编程题1020 Tree Traversals (25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level or...

2018-11-02 15:31:45 128

原创 PAT (Advanced Level) Practice 1004 Counting Leaves (30 分)

编程题1004 Counting Leaves (30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contain...

2018-11-02 10:28:18 141

原创 PAT (Advanced Level) Practice 1118 Birds in Forest (25 分)

编程题1118 Birds in Forest (25 分)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help...

2018-11-01 21:25:52 105

原创 PAT (Advanced Level) Practice 1114 Family Property (25 分)

编程题1114 Family Property (25 分)This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, w...

2018-11-01 20:49:50 111

原创 PAT (Advanced Level) Practice 1107 Social Clusters (30 分)

 1107 Social Clusters (30 分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set...

2018-11-01 15:18:30 148

转载 NumPy 教程

转自:TutorialsPoint NumPy 教程 - 简书https://www.jianshu.com/p/57e3c0a92f3aNumPy - 简介NumPy 是一个 Python 包。 它代表 “Numeric Python”。 它是一个由多维数组对象和用于处理数组的例程集合组成的库。Numeric,即 NumPy 的前身,是由 Jim Hugunin 开发的。 也开发了...

2018-09-18 11:32:52 346

原创 PAT (Advanced Level) Practice 1031 Hello World for U (20)(20 分)

编程题1031 Hello World for U (20)(20 分)Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h de ll rlowo...

2018-07-11 15:51:16 136 1

原创 PAT (Advanced Level) Practice 1027 Colors in Mars (20)(20 分)

编程题1027 Colors in Mars (20)(20 分)People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 dig...

2018-07-11 10:47:49 120

原创 PAT (Advanced Level) Practice 1012 The Best Rank (25)(25 分)

编程题1012 The Best Rank (25)(25 分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus...

2018-07-04 12:42:38 106

原创 PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20)(20 分)

编程题1023 Have Fun with Numbers (20)(20 分)Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which ...

2018-07-03 20:19:16 138

原创 PAT (Advanced Level) Practice 1019 General Palindromic Number (20)(20 分)

编程题1019 General Palindromic Number (20)(20 分)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All...

2018-06-19 20:18:08 144

原创 PAT (Advanced Level) Practice 1011 World Cup Betting (20)(20 分)

编程题1011 World Cup Betting (20)(20 分)With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the ...

2018-06-19 19:53:17 109

原创 PAT (Advanced Level) Practice 1008 Elevator (20)(20 分)

编程题1008 Elevator (20)(20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in spec...

2018-06-19 19:24:39 126

原创 PAT (Advanced Level) Practice 1035 Password (20)(20 分)

编程题1035 Password (20)(20 分)To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to dis...

2018-06-19 11:23:32 158

原创 PAT (Advanced Level) Practice 1005 Spell It Right (20)(20 分)

编程题1005 Spell It Right (20)(20 分)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input fil...

2018-06-18 16:53:39 164

原创 PAT (Advanced Level) Practice 1002 A+B for Polynomials (25)(25 分)

编程题1002 A+B for Polynomials (25)(25 分)This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line c...

2018-06-16 14:41:42 182

原创 PAT (Advanced Level) Practice 1001 A+B Format (20)(20 分)

编程题1001 A+B Format (20)(20 分)Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Inpu...

2018-06-15 19:29:28 140

原创 PAT (Basic Level) Practise (中文)1015. 德才论 (25)

1015. 德才论 (25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Li宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人。凡取人之术,苟不得圣人,君子而与之,与其得小人,不若得愚人。”现给出一批考生的德才分数,请根据司马光的理论给出录取排名。输入格式:...

2018-03-05 22:37:14 138

转载 C++ STL 教程之向量容器实例

C++ STL(标准模板库)是一套功能强大的 C++ 模板类,提供了通用的模板类和函数,这些模板类和函数可以实现多种流行和常用的算法和数据结构,如向量、链表、队列、栈。C++ 标准模板库的核心包括以下三个组件:组件描述容器(Containers)容器是用来管理某一类对象的集合。C++ 提供了各种不同类型的容器,比如 deque、list、vector、map 等。算法(Algorithms)算法作...

2018-03-05 21:09:33 356

转载 C++ 传递数组给函数

C++ 不允许向函数传递一个完整的数组作为参数,但是,您可以通过指定不带索引的数组名来传递一个指向数组的指针。如果您想要在函数中传递一个一维数组作为参数,您必须以下面三种方式来声明函数形式参数,这三种声明方式的结果是一样的,因为每种方式都会告诉编译器将要接收一个整型指针。同样地,您也可以传递一个多维数组作为形式参数。方式 1形式参数是一个指针:void myFunction(int *param)...

2018-03-04 13:13:25 475

转载 C++ 随机数

C++ 随机数在许多情况下,需要生成随机数。关于随机数生成器,有两个相关的函数。一个是 rand(),该函数只返回一个伪随机数。生成随机数之前必须先调用 srand() 函数。下面是一个关于生成随机数的简单实例。实例中使用了 time() 函数来获取系统时间的秒数,通过调用 rand() 函数来生成随机数:实例#include <iostream>#include <ctime&...

2018-03-03 15:28:34 176

转载 三目运算嵌套寻找最大值

问题:寻找三个数a,b,c中的最大值。代码:#include<iostream>using namespace std;int main(){    int a,b,c,d,max;    cout<<"请输入三个数字:";    cin>>a>>b>>c;    max=(d=a>=b?a:b)>=c?d:

2018-03-03 15:04:38 445

空空如也

空空如也

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

TA关注的人

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