自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Binbin的技术博客

编程技术

  • 博客(75)
  • 资源 (4)
  • 收藏
  • 关注

原创 C# 实现归并排序

class Program { static void Main(string[] args) { var data2 = new List<int>() { 10, 4, 5, 3, 1, 6, 8, 6, 2 }; Console.WriteLine("归并排序"); ...

2019-12-03 12:23:57 218

原创 KNN算法的切分效果的演示

KNN算法效果的演示clear;clc;close all% generate point by uniformrng(1);n = 50;xy = unifrnd(0,10, [n, 2]);group = randi(2, [n, 1]);% plotfigure;gscatter(xy(:,1),xy(:,2),group,'br','

2017-08-24 17:14:15 532

原创 洛谷P1601

加法运算的规则如下:1. 从左到右依次计算2. 两个数组的数字对应位置相加,加上上一次的进位(上次进位为上次的和除以10的商),然后对10取余。注意:可以根据题目中数据的大小约束,设置较大的数组,并且两个数组的大小一致,这样有点浪费空间和时间。后面可以用可变数组来优化。i>=0;i--){i < n;i < n;int a[501];int b[501];int c[501];n--

2023-10-15 11:27:55 175

原创 洛谷第P1957

5. 因为每行的输入可能是2个也可能是3个,是根据第一个字符来确定的,需要用到条件来判断,当输入的第一个字符串的第一个字符是a,b,或者c的时候,接下来读入两个整数,否则将已经读入的字符串转化为整数,接着再读入一个整数。6. 需要在循环外定义一个变量表示运算符,当没有更改时,维持上一个运算。1. 字符串转化为字符数组,用到字符串的.c_str()函数。7. 需要用到二维字符数组,先将结果保存下来,然后再输出。4. 字符数字的实际长度获取,用到strlen()函数。

2023-10-10 05:50:39 250

原创 MATLAB实现分支定界法求解整数规划

分支定界法求解整数规划

2023-05-04 16:41:24 1232

原创 欧拉习题40

题目如下:An irrational decimal fraction is created by concatenating the positive integers:0.123456789101112131415161718192021...It can be seen that the 12thdigit of the fractional part is 1.Ifdnrepresents thenthdigit of the fractional part, find ...

2021-11-13 16:55:14 583

原创 欧拉习题39

题目如下Ifpis the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions forp= 120.{20,48,52}, {24,45,51}, {30,40,50}For which value ofp≤ 1000, is the number of solutions maximised?代码clear;...

2021-11-13 16:53:21 653

原创 欧拉习题38

题目如下:Take the number 192 and multiply it by each of 1, 2, and 3:192 × 1 = 192192 × 2 = 384192 × 3 = 576By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)The s

2021-11-13 16:51:27 800

原创 欧拉习题37

题目如下:The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

2021-11-13 16:48:30 746

原创 欧拉习题36

题目如下:The decimal number, 585 = 10010010012(binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Please note that the palindromic number, in either base, may not inclu.

2021-11-13 08:45:57 750

原创 欧拉习题35

题目如下:The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.How many circular primes are t

2021-11-13 00:46:06 667

原创 欧拉习题34

题目如下:145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.Find the sum of all numbers which are equal to the sum of the factorial of their digits.Note: As 1! = 1 and 2! = 2 are not sums they are not included.采用暴力方法clear;clc;close all

2021-11-13 00:17:10 598

原创 欧拉习题33

题目如下The fraction49/98is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that49/98=4/8, which is correct, is obtained by cancelling the 9s.We shall consider fractions like,30/50=3/5, to...

2021-11-12 23:11:01 934

原创 欧拉习题32

题目如下:We shall say that ann-digit number is pandigital if it makes use of all the digits 1 tonexactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing m...

2021-11-12 22:38:23 594

原创 欧拉习题31

题目如下:In the United Kingdom the currency is made up of pound (£) and pence (p). There are eight coins in general circulation:1p, 2p, 5p, 10p, 20p, 50p, £1 (100p), and £2 (200p).It is possible to make £2 in the following way:1×£1 + 1×50p + 2×20p + 1

2021-11-12 12:07:05 1016

原创 欧拉习题30

题目如下:Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:As 1 = is not a sum it is not included.The sum of these numbers is 1634 + 8208 + 9474 = 19316.Find the sum of all the numbers that ..

2021-11-02 11:10:20 663

原创 欧拉习题29

题目如下:Consider all integer combinations ofabfor 2 ≤a≤ 5 and 2 ≤b≤ 5:=4, =8, =16, =32=9, =27, =81, =243=16, =64, =256, =1024=25, =125, =625, =3125If they are then placed in numerical order, with any repeats removed, we get the following sequence...

2021-11-02 11:05:32 563

原创 欧拉习题28

题目如下:Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:2122 23 242520 78 91019 6 12 1118 54 3121716 15 1413It can be verified that the sum of the numbers on the diag...

2021-11-02 10:50:30 559

原创 欧拉习题27

题目如下:Euler discovered the remarkable quadratic formula:It turns out that the formula will produce 40 primes for the consecutive integer values0≤n≤39. However, whenn=40,+40+41=40(40+1)+41is divisible by 41, and certainly whenn=41,+41+41is clearl...

2021-11-02 10:39:34 745

原创 欧拉习题26

题目如下:A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0...

2021-11-01 15:38:20 657

原创 欧拉习题25

题目如下:The Fibonacci sequence is defined by the recurrence relation:Hence the first 12 terms will be:The 12th term, F12, is the first term to contain three digits.What is the index of the first term in the Fibonacci sequence to contain 1000 digi

2021-11-01 15:16:47 520

原创 欧拉习题24

题目如下:A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic pe

2021-11-01 15:02:07 661

原创 欧拉习题23

题目如下:A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.A numbernis called..

2021-11-01 14:52:49 1178

原创 欧拉习题22

题目如下:Usingnames.txt(right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its al..

2021-11-01 14:06:28 584

原创 欧拉习题17

题目如下:If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would

2021-11-01 12:29:45 735

原创 欧拉习题16

题目如下:and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number ?数值计算不行,采用符号计算sum(char(sym(2)^1000)-'0')

2021-11-01 01:15:39 145

原创 欧拉习题15

题目如下:Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.How many such routes are there through a 20×20 grid?这属于经典的排列组合题目,常在小学奥数上出现,一般有两种做法,动态规划和组

2021-11-01 01:08:49 210

原创 欧拉习题14

题目如下:The following iterative sequence is defined for the set of positive integers:n→n/2 (nis even)n→ 3n+ 1 (nis odd)Using the rule above and starting with 13, we generate the following sequence:13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1It...

2021-11-01 00:55:02 241

原创 欧拉习题13

题目如下:Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.371072875339021027987979982208375902465101357402504637693767749000971264812489697007805041701826053874324986199524741059474233309513058123726617309629919422

2021-11-01 00:24:39 199

原创 欧拉习题21

题目如下:Let d(n) be defined as the sum of proper divisors ofn(numbers less thannwhich divide evenly inton).If d(a) =band d(b) =a, wherea≠b, thenaandbare an amicable pair and each ofaandbare called amicable numbers.For example, the pro...

2021-10-31 00:54:53 236

原创 欧拉习题20

题目如下:n! meansn× (n− 1) × ... × 3 × 2 × 1For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.Find the sum of the digits in the number 100!MATLAB需要采用符号计算sum(char...

2021-10-31 00:41:47 169

原创 欧拉习题19

题目为:You are given the following information, but you may prefer to do some research for yourself.1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-e

2021-10-31 00:22:55 163

原创 欧拉习题67

该题目和第18题类似,只是数据大一些By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.3742468 593That is, 3 + 7 + 4 + 9 = 23.Find the maximum total from top to bottom int...

2021-10-28 23:34:22 217

原创 欧拉习题18

最近由于忙,很久不写了,今天和朋友谈到如何学习编程,然后打开了欧拉习题,正好这个题目没有做,想了一下,写了一个方法,记录下来,供爱好者参考题目:By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.3742468 593That is, 3 + 7 + 4 +...

2021-10-28 15:13:14 202

原创 2020年“高教杯”数学建模B题--沙漠穿越问题的建模与求解

前段时间,应MathWorks邀请,做了一期30分钟的视频,主要讲解了2020年数学建模B题目,沙漠穿越问题的建模和求解,这个问题建模难度比较大,尤其是第一问,由于时间有限,只讲解了第一问的部分计算方法,完整的题目的解决方案,会在后期出版的书籍中给出。下面是视频的链接https://www.bilibili.com/video/BV1j44y1q7sb?share_source=copy_web...

2021-07-12 08:13:52 5028

原创 最大上升子串的MATLAB程序实现

cody上有个最长字串问题,比如,数组,x = [8, 24, 7, 35, 23, 52, 39, 64, 78], 最长的严格上升字串为[8, 24, 35, 52, 64, 78], 长度为6这个题目我个人的做法是,构造一个辅助的数组y, y的第i个元素表示,x的第1个元素到x的第i个元素之间,最大的上升字串的长度,关键就是下一步的思路那么y的第i+1个元素的,就是x的1到i的元素中那些小于x的第i+1个元素的辅助数组对应的y的值加1.假设i=4,我们可以看到y(1) = 1, 对应.

2021-04-20 12:07:45 137

原创 欧拉习题12

题目见:https://projecteuler.net/problem=12这个题目涉及到两个知识点:一个是等差数列的求和公式,另外一个是一个数的约数个数公式,MATLAB和Python的实现分别用了两种不同的思路MATLAB代码clear;clc;close allsum(1:find(arrayfun(@(i)prod(accumarray(factor(sum(1:i))',1)+1),... 1:1.5e4)>500,1))Python代码import sy

2021-01-08 00:33:02 359

原创 用MATLAB直接提取变量元素的方法

今天看到知乎上haitao的博客https://zhuanlan.zhihu.com/p/341374091, 想到关于MATLAB的这个索引方法会带来的一些好处,以及自己对链式语法的理解,写下这篇博客。1. 关于函数返回值的属性的直接访问在MATLAB里面,一般是不支持双括号的索引方式,比如我们需要提取魔方矩阵的第二行的元素>> magic(3)(2,:)Error: Indexing with parentheses '()' must appear as the last

2021-01-03 11:00:56 5150

原创 欧拉习题11

题目:https://projecteuler.net/problem=11将文本复制到data.txtMATLAB代码clear;clc;close allfun = @(x)max([prod(diag(x)),... prod(diag(flip(x))),... prod(x),prod(x')]);s3 = max(nlfilter(readmatrix("data.txt"),[4 4],fun),[],'all')python代码import sys

2020-12-23 12:36:57 466

原创 欧拉习题10

题目:https://projecteuler.net/problem=10MATLAB代码>> sum(primes(2e6))ans = 142913828922Python代码import mathprimes = [2]t = 1while t <= 2e6: t += 2 isprime = True for i in primes: if t%i == 0:

2020-12-21 20:51:04 184

Matlab 递归求解八皇后问题

Matlab写的求解八皇后问题的程序,可以求出全部的92个解

2013-03-17

Matlab广度优先搜索求解迷宫问题

本程序用Matlab语言实现广度优先算法求解迷宫问题,其中1表示障碍,0表示通路,2表示入口,3表示出口,5表示行走路线

2013-03-15

MFC调用Opengl实现三维图形的旋转平移缩放

本例子实现画立方体的例子,多面体可以参考此程序,程序实现了三维立体图形的旋转,平移和缩放,旋转通过鼠标左键实现,平移通过方向键实现,缩放通过鼠标滚轮实现

2013-03-14

Matlab深度优先搜索求解迷宫所有解

% 本函数用深度优先遍历(回溯法)来求解迷宫的所有路径 % maze:是迷宫矩阵,其中0表示可以去走的路 % 1表示障碍 % 2表示入口 % 3表示出径 % 5表示路径 % 0 2 0 0 1 % 0 1 1 0 1 % 0 1 3 0 1 % 0 1 0 0 1

2013-03-12

空空如也

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

TA关注的人

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