projectEuler Problem 12.Highly divisible triangular number

视源CVTE嵌入式面试题及参考答案(200+面试题,17万字) 内核模块如何设置? 内核模块是可在运行时动态加载到内核或从内核卸载的代码块。以下是设置内核模块的步骤: 首先,编写内核模块代码。通常使用 C 语言编写,包含必要的头文件,如<linux/init.h>、<linux/module.h>等。在代码中,需要定义模块的初始化函数和清理函数。初始化函数在模块加载时被调用,用于进行模块的初始化工作,如注册设备、分配资源等。清理函数在模块卸载时被调用,用于释放资源、注销设备等。 例如: #include <li 阅读详情

题目链接:12.Highly divisible triangular number

题意:

  

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...

Let us list the factors of the first seven triangle numbers:

 1: 1
 3: 1,3
 6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28

What is the value of the first triangle number to have over five hundred divisors?

求哪个值 有 500个因数

解题思路:
   分解质因数

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll sum(ll i) {  // 求 triangle number
	if(i % 2 == 0) {
		return i / 2 * (i + 1);
	}
	return (i+1) / 2 * i;
}
int solve(ll n) {
	int num = 0, i;
	for(i = 1; i * i < n; i++) {  // 分解质因数
		if(n % i == 0) { // 如果能整除,那么他就有两个因数
			num += 2;
		}
	}
	if(i * i == n) {  // 平方等于n,因数加1
		num++;
	}
	return num;
}
int main() {
	ll ans = 1;
	while(solve(sum(ans)) < 500) {
		ans++;
	}
	cout << sum(ans) << endl;
	return 0;
}

 

STM32入门教程:无人机控制 我们将会一步一步引导您完成无人机的控制代码,包括无人机的姿态控制、飞行控制和通信控制等。第三步:配置无人机姿态控制 无人机的姿态控制是指控制无人机在空中的倾斜和转向。为了实现姿态控制,我们需要使用加速度计和陀螺仪传感器来获取无人机的姿态信息,并使用PID控制算法来控制无人机的姿态。在这一步骤中,您需要根据您使用的具体传感器和控制算法的要求进行更详细的配置和编码。在通信控制中,您需要考虑到通信的稳定性和可靠性。第五步:通信控制 无人机的通信控制是指与地面站或其他设备进行通信,传输飞行数据和接收飞行指令。 阅读详情

相关推荐

鱼眼相机矫正实战:除了棋盘格,试试横向展开和经纬度法(OpenCV4/C++实现对比)

本文对比了鱼眼相机矫正的三种主流方法:棋盘格标定法、横向展开法和经纬度法,通过OpenCV4/C++实战代码解析,帮助开发者在自动驾驶、VR全景拼接和安防监控等场景中选择最适合的技术方案。重点分析了各方法的精度、处理速度和适用场景,为工程实践提供实用指导。

weixin_29032489的博客 283

欧拉计划Problem 12

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 2

401

PLC编程标准之争:IEC61131与IEC61499核心区别与选型指南

在工业自动化领域,PLC编程长期依赖IEC61131标准,它定义了梯形图、结构化文本等语言,通过周期扫描机制保证确定性执行。然而,随着工业4.0和分布式控制场景的兴起,IEC61499以事件驱动模型打破传统范式,让功能块能跨设备协同,实现更灵活的柔性产线和模块化系统。理解两者在程序结构、数据交互、部署方式和实时性上的差异,是选型与工程落地的关键。本文从基础概念出发,剖析执行模型与架构演进,结合一线调试经验,帮助工程师在传统PLC与下一代标准之间做出理性决策。

weixin_27014595的博客 268

[Project Euler] 来做欧拉项目练习题吧: 题目012

                                   [Project Euler] 来做欧拉项目练习题吧: 题目012                                                       周银辉   问题描述: The sequence of triangle numbers is generated by adding the natur...

weixin_34302798的博客 178

CAPL实战:从零构建HEX文件解析器,赋能UDS刷写

本文详细介绍了如何使用CAPL从零构建HEX文件解析器,以支持UDS刷写操作。通过解析HEX文件格式、设计状态机、优化数据结构与算法,实现高效准确的固件数据处理,并提供了与UDS刷写流程对接的工程化实践建议。

weixin_28726391的博客 443

Linear超高PSRR线性稳压器-典型应用电路解析

本文整理完了LT3045数据手册内所有的典型应用电路,试图让沉默的电路开口,简单介绍了他们这样做的目的和原理,从中我们可以更加熟悉这颗经典芯片的应用。但也有一些电路并没有搞懂,遗留下了不少问题。

硬件工程师笔记 2940

欧拉计划问题十二matlab实现

Problem 12 : The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be                   1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms wou...

凤羽matlab的博客 1065

CH341的I2C流模式(StreamI2C)到底怎么用?从EEPROM读写到自定义设备,一篇讲清参数配置逻辑

本文详细解析了CH341的I2C流模式(StreamI2C)的使用方法,从EEPROM读写到自定义设备的参数配置逻辑。通过深入分析I2C协议基础、StreamI2C参数映射关系及典型设备配置示例,帮助开发者快速掌握StreamI2C的应用技巧,解决实际开发中的常见问题。

weixin_30932215的博客 447

用clojure解决euler problem 12

问题描述: The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 1...

独立之人格,自由之思想 234

jmeter问题系列:Begin size 0 is not equal to fixed size 5

Begin size 0 is not equal to fixed size 5 ,问题的解决

雨水的早晨的博客 2411

AutoSAR系列讲解(入门篇)1.2-AutoSAR概述

这里主要说明了AutoSAR是个什么,还有其工具链

雪云飞星的博客 5万+

Project Euler:Problem 12 Highly divisible triangular number

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28,

312小公举的专栏 739

有效Dk值提取方法的仿真分析

通过本文的仿真对比分析,提取有效Dk值方面,TDR技术在一些固定的场景下,依然有其参考应用价值,而随着VNA功能的不断增强和高精度测量手段的不断更新,双端口Delta-L技术才是主流评估方法,而单端口Delta-L技术则可以作为其降本增效的方案补充。

一只豌豆象的博客 1824

ProjectEuler-Problem 12-Highly divisible triangular number

# @Time    : 2017/5/20 20:39 # @Author  : wanyang # @Mail    :wanyangnumberone@gmail.com # @Question:Highly divisible triangular number   https://projecteuler.net/problem=12 # @Answer  :76576500

万杨的博客 345

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

gym I. Painting the natural numbers

这道数学题 刚开始以为按照样例的规律那样输出就可以了,但是wa了几发打表发现显然是错误的,样例只能到1023,而打表的规律可以做到大于1024. 然后曾想到0110222220110,这种方法,只是猜测,但是感觉好像并不正确就没有提交 然后搜了题解,发现这个方法是对的。。也不知道怎么证明的正确性。 因为0110后面加个2,可以连续加前面所有数+1个,然后后面只要前面出现过的数字即可。 每

yeleng的博客 318

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Project Euler 第12题

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 2...

Lam Peter's blog 264

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Project Euler Problem 12

Problem 12The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15,...

wxinbeings的博客 208

EularProject 12: 三角形数的因子个数问题

Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.

掉下个小石头 2073

Project Euler Problem 12: Highly divisible triangular number

Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. T

海岛Blog 951

欧拉计划 第十二题

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15, 21, 28, 3...

qq_38362049的博客 688

Java进阶之欧拉工程 第十二篇【有大量约数的三角数】

原题如下: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6,

demon的专栏 727

Highly divisible triangular number( Problem 12)

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28,

http://kingim.cn/ 1379

[Project Euler] Problem 12

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 2...

weixin_30346033的博客 165

N!的标准分解

定理: 在 n! 的标准分解式 中 ,素数 P的最高指数 p(n ! ) = [n/p]+ [n/p2]+ … + [ n/pk ]. [n/p] :n/p 向下取整 , p 为不大于n的所有素数 n! = p1^p1(n!) * p2^p2(n!) * p3^p3(n!) ........pn^pn(n!) pn 为小于n的最大素数 举例: n = 6; 小于等于 6 的素数 为 2,3 2(6!) = [6/2] + [6/(2^2)] = 3+1 = 4; 3(6!) = [6/3] = 2; 5(6

error311的博客 3803

扩展欧几里得算法 求解 丢番图方程

丢番图方程: 有一个或者几个变量的整系数方程,它们的求解仅仅在整数范围内进行。 a * x + b * y = c ( 其中所有数均为整数, 已知 x, y, c) 例如:鸡兔同笼问题. 扩展欧几里得算法: 拓展欧几里得算法是基于欧几里得算法而来解 一类特殊的线性丢番图方程:a * x + b * y = gcd(a,b) (已知 a, ...

error311的博客 1157

LeetCode 1551. 使数组中所有元素相等的最小操作数

题目链接:1551. 使数组中所有元素相等的最小操作数 题意: 存在一个长度为 n 的数组 arr ,其中 arr[i] = (2 * i) + 1 ( 0 <= i < n )。 一次操作中,你可以选出两个下标,记作 x 和 y ( 0 <= x, y < n )并使 arr[x] 减去 1 、arr[y] 加上 1 (即 arr[x] -=1 且 arr[y] += 1 )。最终的目标是使数组中的所有元素都 相等 。题目测试用例将会 保证 :在执行若干步操作后,...

error311的博客 674
上一篇: LeetCode 79. 单词搜索
下一篇: PHP安装新的扩展模块
error0318
博客等级 码龄9年 57粉丝 515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值