自定义博客皮肤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)
  • 资源 (5)
  • 论坛 (2)
  • 收藏
  • 关注

原创 PAT甲级 1045. Favorite Color Stripe (30)

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...

2019-05-23 22:18:40 182

原创 PAT甲级 1057. Stack (30) 【树状数组/线段树】

Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and Po...

2019-05-23 18:49:38 344

原创 OpenMP并行实现枚举排序

程序通过生成随机数组,利用OpenMP实现并行化的枚举排序算法,并与串行算法进行了比较。#include <omp.h>#include <time.h>#include <string.h>#include <stdio.h>#define maxn 100000#define NUM_THREADS 20int n;int ...

2019-05-21 16:11:42 846

原创 OpenMP 互斥锁函数

OpenMP API所提供的互斥函数可放在任意需要的位置。程序员必须自己保证在调用相应锁操作之后释放相应的锁,否则就可能造成多线程程序的死锁。下面为OpenMP API函数提供的互斥函数和可嵌套的互斥锁函数。void omp_init_lock(omp_lock*):初始化互斥器void omp_destroy_lock(omp_lock*):销毁互斥器void omp_set_lock(...

2019-05-21 16:08:43 1098

原创 OpenMP critical临界区

临界区用在可能产生数据访问竞争的地方,用法:#pragma omp critical (name) (name可省略)。保证每次只有一个线程进入。注意:critical语句不允许互相嵌套例:在一个并行域内的for任务分担域中,各个线程逐个进入到critical保护的区域内,比较当前元素的最大值得关系并可能进行最大值的更替,从而避免了数据竞争的情况。#include <stdio.h&g...

2019-05-21 16:07:36 864

原创 OpenMP并行计算矩阵向量相乘

程序计算随机生成的矩阵与向量相乘函数f():单线程计算函数fp():多线程并行计算#include <stdio.h>#include <omp.h>#include <stdlib.h>#include <time.h>const int NUM_THREADS = 20;typedef long long ll;int m ...

2019-05-21 16:06:19 3454

原创 OpenMP编程

1. 执行模式概述:OpenMP是跨平台的多核多线程编程的一套指导性的编译处理方案(Compiler Directive),指导编译器将代码编译为多线程程序。Openmp的执行模型采用fork-join的形式,其中fork(派生)创建新线程或者唤醒已有线程;join即多线程的会合。[image:2DCC5666-87E6-475C-9A7B-A94C61A4D4C1-563-000023...

2019-05-21 15:57:37 921

原创 PAT甲级 1134 Vertex Cover (25 分)

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...

2019-05-20 11:03:24 168

原创 PAT甲级 1135 Is It A Red-Black Tree (30 分) 【红黑树】

There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3) Every le...

2019-05-19 21:22:09 334

原创 1136 A Delayed Palindrome (20 分) 【大数加法】

Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​ ⋯a​1​​ a​0​​ with 0≤a​i​​ <10 for all i and a​k​​ >0. Then N is palindromic if and only if...

2019-05-19 18:19:46 357

原创 PAT甲级1137 Final Grading (25)

For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from...

2019-05-19 17:32:23 244 1

原创 PAT 甲级 1138 Postorder Traversal (25 分)

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...

2019-05-19 12:13:31 99

原创 使用unordered_set&lt;pair&lt;int,int&gt;&gt; unordered_map&lt;pair&lt;int,int&gt;, bool&gt;

本文介绍C++11特性下使用unordered_set<pair<int, int>>与unordered_map<pair<int, int>, bool>的方法,int换为其他数据类型方法一致。众所周知,基于红黑树(RB-Tree)的set与map是可以使用std::pair的,而unoredered_set与unordered_map的内部实...

2019-05-19 10:52:41 5102

原创 PAT 甲级 1139 First Contact (30 分)【模拟好题】

Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly i...

2019-05-19 09:42:35 380

原创 PAT甲级 1140 Look-and-say Sequence (20 分)

Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, …where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number....

2019-05-18 19:55:53 145

原创 PAT 甲级 1142 Maximal Clique (25 分)

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...

2019-05-18 12:31:18 123

原创 PAT甲级 1143 Lowest Common Ancestor (30 分)【LCA】

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has t...

2019-05-18 11:32:15 130

原创 PAT甲级 1144 The Missing Number (20 分)

Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives...

2019-05-18 08:57:17 134

原创 PAT甲级 1145 Hashing - Average Search Time (25 分) 【哈希 二次探测法】

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...

2019-05-17 22:12:50 163

原创 PAT甲级 1146 Topological Order (25 分) 【拓扑排序】

This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...

2019-05-17 21:18:35 216

原创 PAT甲级 1147 Heaps (30 分)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-05-17 19:48:26 121

原创 PAT甲级 1148 Werewolf - Simple Version (20 分)

Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: “Player #2 is a werewolf.”;player #2 said: ...

2019-05-17 14:59:45 132

原创 PAT甲级 1149 Dangerous Goods Packaging (25 分)

When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂)...

2019-05-17 10:47:56 117

原创 PAT甲级 1150 Travelling Salesman Problem (25 分) 【哈密顿回路】

The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...

2019-05-17 10:27:47 156

原创 PAT甲级 1151 LCA in a Binary Tree (30 分) 【LCA】

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Inpu...

2019-05-16 19:21:35 154

原创 PAT甲级 1152 Google Recruitment (20 分)【字符串模拟】

In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit p...

2019-05-16 17:38:12 110

原创 PAT甲级 1153 Decode Registration Card of PAT 【字符串模拟】

A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;the 2nd - 4th digits are the test site numb...

2019-05-16 15:55:04 120

原创 PAT甲级 1155 Heap Paths【堆 dfs】

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-05-16 10:46:58 113

原创 POJ 1845 Sumdiv【乘法逆元+费马小定理】

DescriptionConsider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the two...

2019-05-10 21:29:23 85

原创 【算法竞赛进阶指南】NOIP2011/CH3601 计算系数 【组合计数 阶乘逆元 费马小定理】

题目描述给定一个多项式(ax+by)k(ax+by)^k(ax+by)k,请求出多项式展开后xnymx^ny^mxnym项的系数。输入格式共一行,包含 5 个整数,分别为 a,b,k,n,m,每两个整数之间用一个空格隔开。输出格式输出共 1 行,包含一个整数,表示所求的系数,这个系数可能很大,输出对10007 取模后的结果。数据范围0≤n,m≤k≤1000,n+m=k,0≤a,b...

2019-05-10 20:51:01 109

原创 POJ 3696 The Luckiest Number 【欧拉函数+快速幂】

DescriptionChinese people think of ‘8’ as the lucky digit. Bob also likes digit ‘8’. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among...

2019-05-10 17:43:17 103

原创 FZU 1759 Super A^B mod C 【欧拉函数 降幂公式】

Problem DescriptionGiven A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000).InputThere are multiply testcases. Each testcase, there is on...

2019-05-10 15:57:51 99

原创 POJ3090 Visible Lattice Points 【欧拉函数+欧式筛法】

在一个平面直角坐标系的第一象限内,如果一个点(x,y)与原点(0,0)的连线中没有通过其他任何点,则称该点在原点处是可见的。例如,点(4,2)就是不可见的,因为它与原点的连线会通过点(2,1)。部分可见点与原点的连线如下图所示:编写一个程序,计算给定整数N的情况下,满足0≤x,y≤N的可见点(x,y)的数量(可见点不包括原点)。输入格式第一行包含整数C,表示共有C组测试数据。每组测试...

2019-05-10 14:55:46 160

原创 【算法竞赛进阶指南】CH5401 没有上司的舞会 树形dp

Ural大学有N名职员,编号为1~N。他们的关系就像一棵以校长为根的树,父节点就是子节点的直接上司。每个职员有一个快乐指数,用整数 Hi 给出,其中 1≤i≤N。现在要召开一场周年庆宴会,不过,没有职员愿意和直接上司一起参会。在满足这个条件的前提下,主办方希望邀请一部分职员参会,使得所有参会职员的快乐指数总和最大,求这个最大值。输入格式第一行一个整数N。接下来N行,第 i 行表示 i...

2019-05-09 21:04:08 137

原创 【算法竞赛进阶指南】NOI1995 CH3501 石子合并 区间DP

设有N堆沙子排成一排,其编号为1,2,3,…,N。每堆沙子有一定的质量,可以用一个整数来描述,现在要将这N堆沙子合并成为一堆。每次只能合并相邻的两堆,合并的代价为这两堆沙子的质量之和,合并后与这两堆沙子相邻的沙子将和新堆相邻,合并时由于选择的顺序不同,合并的总代价也不相同。例如有4堆沙子分别为 1 3 5 2, 我们可以先合并1、2堆,代价为4,得到4 5 2, 又合并 1,2堆,代价为9,...

2019-05-09 20:53:22 183

原创 【算法竞赛进阶指南】CH5202 自然数拆分Lunatic版 完全背包

给定一个自然数N,要求把N拆分成若干个正整数相加的形式,参与加法运算的数可以重复。求拆分的方案数 mod 2147483648的结果。输入格式一个自然数N。输出格式输入一个整数,表示结果。数据范围1 ≤ N ≤ 4000输入样例:7输出样例:141~N这N个自然数构成N种物品,每种物品都可以无限次使用,背包容积为N,求方案数(求和)。注意2147483648这个数超出了...

2019-05-09 20:00:16 167

原创 【算法竞赛进阶指南】CH5103 NOIP2008 T3 传纸条 线性dp

Description给定一个 N*M 的矩阵A,每个格子中有一个整数。现在需要找到两条从左上角 (1,1) 到右下角 (N,M) 的路径,路径上的每一步只能向右或向下走。路径经过的格子中的数会被取走。两条路径不能经过同一个格子。求取得的数之和最大是多少。N,M≤50。数据规模约定:30%的数据满足:1<=m,n<=10100%的数据满足:1<=m,n<=50In...

2019-05-09 17:00:19 150

原创 【算法竞赛进阶指南】CH1807 Necklace 字符串最小表示法

有一天,达达捡了一条价值连城的宝石项链,但是,一个严重的问题是,他并不知道项链的主人是谁!在得知此事后,很多人向达达发来了很多邮件,都说项链是自己的,要求他归还(显然其中最多只有一个人说了真话)。达达要求每个人都写了一段关于自己项链的描述: 项链上的宝石用数字0至9来标示。一个对于项链的表示就是从项链的某个宝石开始,顺指针绕一圈,沿途记下经过的宝石,比如项链: 0-1-2-3 ,它的可能的四...

2019-05-09 12:40:42 149

原创 【算法竞赛进阶指南】CH1802 表达式计算4 表达式计算模板

给出一个表达式,其中运算符仅包含+,-,*,/,^(加 减 乘 整除 乘方)要求求出表达式的最终值。数据可能会出现括号情况,还有可能出现多余括号情况。数据保证不会出现大于或等于231的答案。数据可能会出现负数情况。输入格式输入仅一行,即为表达式。输出格式输出仅一行,既为表达式算出的结果。输入样例:(2+2)^(1+1)输出样例:16真正的表达式计算万能模板啊。#incl...

2019-05-08 20:43:14 278

原创 【算法竞赛进阶指南】CH4302 Interval GCD 线段树套树状数组

题目描述给定一个长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“C l r d”,表示把 A[l],A[l+1],…,A[r] 都加上 d。2、“Q l r”,表示询问 A[l],A[l+1],…,A[r] 的最大公约数(GCD)。对于每个询问,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行表示M条指令,每条指令的格式如题目...

2019-05-08 16:44:45 198 2

2015年数模国赛b题数据

包含北京、西安、南京、成都四个城市2016年8月6日-12日每日0点-12点内的demand(打车需求量) distribute(出租车分布) money(车费) response(被抢单时间) satisfy(打车难易度) 五种信息

2018-08-26

调用sklearn库的K-Means聚类分析实例

#class sklearn.cluster.KMeans(n_clusters=8, init=’k-means++’, n_init=10, max_iter=300, tol=0.0001, precompute_distances=’auto’, verbose=0, random_state=None, copy_x=True, n_jobs=1, algorithm=’auto’) #参数: #(1)对于K均值聚类,我们需要给定类别的个数n_cluster,默认值为8; #(2)max_iter为迭代的次数,这里设置最大迭代次数为300; #(3)n_init设为10意味着进行10次随机初始化,选择效果最好的一种来作为模型; #(4)init=’k-means++’ 会由程序自动寻找合适的n_clusters; #(5)tol:float形,默认值= 1e-4,与inertia结合来确定收敛条件; #(6)n_jobs:指定计算所用的进程数; #(7)verbose 参数设定打印求解过程的程度,值越大,细节打印越多; #(8)copy_x:布尔型,默认值=True。当我们precomputing distances时,将数据中心化会得到更准确的结果。如果把此参数值设为True,则原始数据不会被改变。如果是False,则会直接在原始数据上做修改并在函数返回值时将其还原。但是在计算过程中由于有对数据均值的加减运算,所以数据返回后,原始数据和计算前可能会有细小差别。 #属性: #(1)cluster_centers_:向量,[n_clusters, n_features] # Coordinates of cluster centers (每个簇中心的坐标??); #(2)Labels_:每个点的分类; #(3)inertia_:float,每个点到其簇的质心的距离之和。

2018-01-26

python爬取淘宝商品信息

import requests from bs4 import BeautifulSoup import bs4 def getHTMLText(url): try: r = requests.get(url, timeout=30) r.raise_for_status() r.encoding = r.apparent_encoding return r.text except: return "" def fillUnivList(ulist, html): soup = BeautifulSoup(html, "html.parser") for a in soup.find('tbody').children: if isinstance(a, bs4.element.Tag): tds = a('td') ulist.append([tds[0].string, tds[1].string, tds[2].string, tds[3].string]) def printUnivList(ulist, num): print("{:^10}\t{:^6}\t{:^6}\t{:^16}".format("排名","学校名称","地区","总分")) for i in range(num): u=ulist[i] print("{:^10}\t{:^6}\t{:^6}\t{:^16}".format(u[0],u[1],u[2],u[3]))

2018-01-26

2019蓝桥杯.zip

2019年蓝桥杯B组省赛C/C++试题,包括PDF文件、A-J题全部试题的图片、数据等。试题解析可以参考:https://blog.csdn.net/zhaohaibo_/article/details/88783978

2019-11-12

ACM校赛题解.pptx

ACM校赛

2019-10-26

Iovebecky的留言板

发表于 2020-01-02 最后回复 2020-01-02

考研 计算机和软件工程差别很大吗?

发表于 2019-09-10 最后回复 2019-09-10

空空如也

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

TA关注的人 TA的粉丝

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