自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Java 线程池使用总结

基本知识Runnable接口Runnable接口只有一个run()方法 ,并且该方法无返回值public interface Runnable { public abstract void run();}Callable接口Callable接口也只有一个call()方法,但是该方法有具体的返回值public interface Callable<V> { V call() throws Exception;}Callable与

2021-12-02 10:17:28 196

原创 使用JProfile进行优化笛卡尔乘积运算,提高性能

利用JProfile优化笛卡尔乘积运算,提高性能项目场景项目需要对嵌套的集合进行笛卡尔乘积运算,具体要求为:给定一个嵌套的集合S1=[S11,S12,...,S1k]S1=[S1_1,S1_2,...,S1_k]S1=[S11​,S12​,...,S1k​],其中S1iS1_iS1i​是由单元素构成的集合,另一个集合S2S2S2也是由单元素构成的,需要实现集合S1S1S1与S2S2S2的笛卡尔乘积。代码实现原本为:大致思路是使用双层循环,这里cur代表上述的S1S1S1,next代表上述S2S2S2

2021-11-26 23:11:30 353

原创 Java Thread API介绍与应用

第三章:Thread API的详细介绍API功能使用sleep使当前线程进入休眠,暂停执行Thread.sleep()TimeUnit.sleep() //推荐使用yield使当前线程从RUNNING状态切换到RUNNABLE状态,当CPU资源不紧张时,会被忽略;set/getPriority设置/获取当前线程的优先级1≤优先级≤101 \le 优先级 \le 101≤优先级≤10不超过所在group的优先级通常不指定getId获取当前线程的Id

2021-11-16 19:32:18 589

原创 微信小程序vant上传图片并利用canvas压缩

项目场景项目中需要用户在小程序中上传图片,使用vant中的组件上传,并且在上传服务器前对图片进行压缩,以减小存储空间占用。问题分析微信小程序从基础库2.7版本开始,使用新的 Canvas api, 网上很多博客中所给出的解决方案在新的api下不能工作,主要的变化有如下几点:Canvas对象的获取:Image对象的获取:此外,在实践过程中,出现canvas绘制的图像内容为空的问题,对应的临时图片地址也无法在微信开发者工具中打开,经过debug发现,Image.onload对应的回调函数里的ct

2021-08-18 00:37:33 1183

原创 Rust 所有权

Rust 所有权基本原则:Rust 中的每个值都有一个变量,称为其所有者。一次只能有一个所有者。当所有者不在程序运行范围时,该值将被删除。变量与数据交互的方式变量与数据交互的方式:移动(move)和克隆(clone)两种:如果我们定义了一个变量并给它赋予一个值,这个变量的值存在于内存中;如果我们需要储存的数据长度不确定(比如用户输入的一串字符串),我们就无法在定义时明确数据长度,也就无法在编译阶段令程序分配固定长度的内存空间供数据储存使用, 这就需要提供一种在程序运行时程序自己申请使

2021-06-16 18:49:16 332

原创 P1230 智力大冲浪

P1230 智力大冲浪题目描述小伟报名参加中央电视台的智力大冲浪节目。本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元。先不要太高兴!因为这些钱还不一定都是你的?!接下来主持人宣布了比赛规则:首先,比赛时间分为n个时段(n≤500),它又给出了很多小游戏,每个小游戏都必须在规定期限ti前完成(1≤ti≤n)。如果一个游戏没能在规定期限前完成,则要从奖励费m元中扣去一部分钱w

2018-03-16 21:12:44 839

原创 L2-015. 互评成绩

L2-015. 互评成绩题目描述学生互评作业的简单规则是这样定的:每个人的作业会被k个同学评审,得到k个成绩。系统需要去掉一个最高分和一个最低分,将剩下的分数取平均,就得到这个学生的最后成绩。本题就要求你编写这个互评系统的算分模块。Iutput输入第一行给出3个正整数N(3< N <= 104,学生总数)、k(3<= k <= 10,每份作业的评审数)、M(<= 20,需要输出的学生数)。随后N行,

2018-03-09 23:01:38 268

原创 L2-013. 红色警报

L2-013. 红色警报题目描述战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。Iutput输入在第一行给出两个整数N(0 < N <=500)和M(<=5000),分别为城市个数(于是默认城市从0到N-1编

2018-03-07 11:21:49 287

原创 L2-010. 排座位

L2-010. 排座位题目描述布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。Iutput输入第一行给出3个正整数:N(<= 100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之间的关系

2018-03-06 23:08:50 276

原创 L2-009. 抢红包

L2-009. 抢红包题目描述没有人没抢过红包吧…… 这里给出N个人之间互相发红包、抢红包的记录,请你统计一下他们抢红包的收获。Iutput输入第一行给出一个正整数N(<= 104),即参与发红包和抢红包的总人数,则这些人从1到N编号。随后N行,第i行给出编号为i的人发红包的记录,格式如下:K N1 P1 … NK PK其中K(0 <= K <= 20)是发出去的红包个数,Ni是抢到红包的人的编号,

2018-03-06 22:12:59 307

原创 L2-008. 最长对称子串

L2-008. 最长对称子串对给定的字符串,本题要求你输出最长对称子串的长度。例如,给定”Is PAT&TAP symmetric?”,最长对称子串为”s PAT&TAP s”,于是你应该输出11。题目描述输入在一行中给出长度不超过1000的非空字符串。Iutput输入在一行中给出长度不超过1000的非空字符串。Output在一行中输出最长对称子串的长度。Sample InputIs PAT&TAP

2018-03-06 20:18:57 290

原创 L2-007. 家庭房产

L2-007. 家庭房产题目描述给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。Iutput输入第一行给出一个正整数N(<=1000),随后N行,每行按下列格式给出一个人的房产: 编号 父 母 k 孩子1 … 孩子k 房产套数 总面积其中 编号 是每个人独有的一个4位数的编号;父 和 母 分别是该编号对应的这个人的父母的编号(如果已经过世,则显示-1);

2018-03-05 11:21:06 328

原创 L2-005. 集合相似度

L2-005. 集合相似度题目描述给定两个整数集合,它们的相似度定义为:Nc/Nt*100%。其中Nc是两个集合都有的不相等整数的个数,Nt是两个集合一共有的不相等整数的个数。你的任务就是计算任意一对给定集合的相似度。Iutput输入第一行给出一个正整数N(<=50),是集合的个数。随后N行,每行对应一个集合。每个集合首先给出一个正整数M(<=104),是集合中元素的个数;然后跟M个[0, 109]

2018-03-04 21:20:31 238

原创 L2-003. 月饼

L2-003. 月饼题目描述月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有3种月饼,其库存量分别为18、15、10万吨,总售价分别为75、72、45亿元。如果市场的最大需求量只有20万吨,那么我们最大收益策略应该是卖出

2018-03-04 20:25:44 210

原创 F - 最长公共子序列

F - 最长公共子序列题目描述A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, …, xm > another sequence Z = < z1, z2, …, zk > is a su

2018-02-20 11:44:09 305

原创 E - 01背包

E - 01背包题目描述Bessie has gone to the mall’s jewelry store and spies a charm bracelet. Of course, she’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each char

2018-02-20 11:40:15 260

原创 I - 素数环 搜索

素数环 搜索题目描述A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the numb

2018-02-20 11:36:15 236

原创 Z - Bitset

Z - Bitset题目描述Give you a number on base ten,you should output it on base two.(0 < n < 1000)IutputFor each case there is a postive number n on base ten, end of file.OutputFor each case output a number o

2018-02-20 11:31:41 310

原创 Y - 栈

Y - 栈题目描述How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TROT to TORT: [ i i i i o o o o i o i i o o i o ] where i stands

2018-02-20 11:28:55 397

原创 X - 栈

X - 栈题目描述As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest al

2018-02-20 11:24:38 315

原创 W - stl 的 优先队列

stl 的 优先队列题目描述Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning and walk back every evening. Walking may cause a little tired, so Sempr always play some games t

2018-02-20 11:15:47 271

原创 Q - 贪心

贪心题目描述When playing DotA with god-like rivals and pig-like team members, you have to face an embarrassing situation: All your teammates are killed, and you have to fight 1vN.There are two key attributes

2018-02-20 11:10:45 243

原创 P - 贪心

贪心题目描述Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework aft

2018-02-18 23:25:28 234

原创 O - Number Sequence

Number Sequence题目描述A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2…Sk. Each group Sk consists of a sequence of po

2018-02-18 23:19:55 551

原创 N - A + B Again

B Again题目描述There must be many A + B problems in our HDOJ , now a new one is coming. Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too. Ea

2018-02-18 23:12:29 320

原创 G - stl 的 优先队列

stl 的 优先队列题目描述In a speech contest, when a contestant finishes his speech, the judges will then grade his performance. The staff remove the highest grade and the lowest grade and compute the average of

2018-02-18 23:07:13 324

原创 F - 递推

递推题目描述我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。 Iutput输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0Output对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。 Sample Inpu

2018-02-18 22:54:22 217

原创 E - 贪心

贪心题目描述FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J[i] pounds

2018-02-18 22:48:56 236

原创 C - stl 的 map

stl 的 map题目描述夏天来了~~ 好开心啊,呵呵,好多好多水果 ~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了. Iutput第一行正整数N(0Output对于每一组测试数据,请你输出一份排版格式正确(请分析样本输出)的水果销售情况明细表.这份明细表包括所有水果的产地,名称和销

2018-02-18 22:19:42 247

原创 B - stl 的 map

stl 的 map题目描述Ignatius is so lucky that he met a Martian yesterday. But he didn’t know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ig

2018-02-18 22:02:48 326

原创 A - stl 的 map

stl 的 map题目描述Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most popular problem. When the contest is over, t

2018-02-18 21:52:18 207

原创 Z - A + B Problem II

A + B Problem II题目描述I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. IutputThe first line of the input contains an integer T(1<=T<=20) which

2018-02-18 21:43:50 189

原创 Y - A == B ?

A == B ?题目描述Give you two numbers A and B, if A is equal to B, you should print “YES”, or print “NO”.Iutputeach test case contains two numbers A and B. Outputfor each case, if A is equal to B, you shoul

2018-02-17 21:49:50 313

原创 X - Specialized Four-Digit Numbers

Specialized Four-Digit Numbers题目描述Find and list all four-digit numbers in decimal notation that have the property that the sum of its four digits equals the sum of its digits when represented in hexade

2018-02-17 21:46:42 220

原创 W - The Circumference of the Circle

The Circumference of the Circle题目描述To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don’t? You are given the cartesian coordinates o

2018-02-17 21:40:43 224

原创 V - The Fun Number System

The Fun Number System题目描述In a k bit 2’s complement number, where the bits are indexed from 0 to k-1, the weight of the most significant bit (i.e., in position k-1), is -2^(k-1), and the weight of a bit

2018-02-17 21:29:51 284

原创 U - Long Distance Racing

Long Distance Racing题目描述Bessie is training for her next race by running on a path that includes hills so that she will be prepared for any terrain. She has planned a straight path and wants to run as f

2018-02-17 21:25:51 263

原创 R - Joseph

Joseph题目描述The Joseph’s problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, …, n, standing in circle every mth is going to be exec

2018-02-17 11:02:44 277

原创 O - Dirichlet's Theorem on Arithmetic Progressions

Dirichlet’s Theorem on Arithmetic Progressions题目描述If a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d

2018-02-17 10:54:03 271

原创 N - Bullseye

Bullseye题目描述A simple dartboard consists of a flat, circular piece of cork with concentric rings drawn on it. Darts are thrown at the board by players in an attempt to hit the center of the dartboard (t

2018-02-17 10:48:29 270

空空如也

空空如也

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

TA关注的人

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