题意: 记d(n)为n的所有真因数(小于n且整除n的正整数)之和. 如果d(a) = b且d(b) = a,且a ≠ b,那么a和b构成一个亲和数对,a和b被称为亲和数. 例如,220的真因数包括1.2.4.5.10.11.20.22.44.55和100,因此d(220) = 284:而284的真因数包括1.2.4.71和142,因此d(284) = 220. 求所有小于10000的亲和数的和. 整数因子和: <font color = red , size = 5 >以下图片仅供学习!图片来…
题意: 首次出现连续两个数均有两个不同的质因数是在: 14 = 2 × 715 = 3 × 5 首次出现连续三个数均有三个不同的质因数是在: 644 = 22 × 7 × 23645 = 3 × 5 × 43646 = 2 × 17 × 19 首次出现连续四个数均有四个不同的质因数时,其中的第一个数是多少? 方法一:普通筛法 /************************************************************************* > File Name…
题意: 完全数是指真因数之和等于自身的那些数.例如,28的真因数之和为1 + 2 + 4 + 7 + 14 = 28,因此28是一个完全数. 一个数n被称为亏数,如果它的真因数之和小于n:反之则被称为盈数. 由于12是最小的盈数,它的真因数之和为1 + 2 + 3 + 4 + 6 = 16,所以最小的能够表示成两个盈数之和的数是24.通过数学分析可以得出,所有大于28123的数都可以被写成两个盈数的和:尽管我们知道最大的不能被写成两个盈数的和的数要小于这个值,但这是通过分析所能得到的最好上界.…
The first two consecutive numbers to have two distinct prime factors are: 14 = 2  7 15 = 3  5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2²  7  23 645 = 3  5  43 646 = 2  17  19. Find the first four consecutiv…
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 × 7 15 = 3 × 5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2² × 7 × 23 645 = 3 × 5 × 43 646 = 2 × 17 × 19. Find the first four co…
题意: 考虑所有满足2 ≤ a ≤ 5和2 ≤ b ≤ 5的整数组合生成的幂ab: 22=4, 23=8, 24=16, 25=3232=9, 33=27, 34=81, 35=24342=16, 43=64, 44=256, 45=102452=25, 53=125, 54=625, 55=3125 如果把这些幂按照大小排列并去重,我们得到以下由15个不同的项组成的序列: 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 31…
题意: 欧拉发现了这个著名的二次多项式: f(n) = n2 + n + 41 对于连续的整数n从0到39,这个二次多项式生成了40个素数.然而,当n = 40时402 + 40 + 41 = 40(40 + 1) + 41能够被41整除,同时显然当n = 41时,412 + 41 + 41也能被41整除. 随后,另一个神奇的多项式n2 − 79n + 1601被发现了,对于连续的整数n从0到79,它生成了80个素数.这个多项式的系数-79和1601的乘积为-126479. 考虑以下形式的二次多…
题意:3797有着奇特的性质.不仅它本身是一个素数,而且如果从左往右逐一截去数字,剩下的仍然都是素数:3797.797.97和7:同样地,如果从右往左逐一截去数字,剩下的也依然都是素数:3797.379.37和3.只有11个素数,无论从左往右还是从右往左逐一截去数字,剩下的仍然都是素数,求这些数的和.注意:2.3.5和7不被视为可截素数. /************************************************************************* > Fi…
题意:197被称为圆周素数,因为将它逐位旋转所得到的数:197/971和719都是素数.小于100的圆周素数有十三个:2.3.5.7.11.13.17.31.37.71.73.79和97.小于一百万的圆周素数有多少个? /************************************************************************* > File Name: euler035.c > Author: WArobot > Blog: http://www.…
从一开始按以下方式逆时针旋转,可以形成一个边长为七的正方形螺旋: 一个有趣的现象是右下对角线上都有一个奇完全平方数,但是更有趣的是两条对角线上的十三个数中有八个数是素数(已经标红),也就是说素数占比为\(8/13\approx62\%\).如果在上面的螺旋再加一层就可以形成一个边长为九的正文形螺旋.如果这个过程继续下去,在边长为多少的时候两条对角线上的数字中质数占比会低于10%? 分析:这道题和第二十八题非常类似,只不过二十八题是顺时针旋转,所以是右上角元素是完全平方数,而这道题是逆时针旋转,所…
本题来自 Project Euler 第12题:https://projecteuler.net/problem=12 # 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…
上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出这道题的人) program 4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.…
project euler 169 题目链接:https://projecteuler.net/problem=169 参考题解:http://tieba.baidu.com/p/2738022069 #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define rep(i, a, b) for(i…
题目链接: https://projecteuler.net/problem=501 题意: \(f(n)\) be the count of numbers not exceeding \(n\) with exactly eight divisors. 就是找少于等于 \(n\)中只有8个因子的个数. You are given \(f(100) = 10, f(1000) = 180\) and \(f(10^6) = 224427\). Find \(f(10^{12})\) 题解: 我…
本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable numbers Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b…
本题来自 Project Euler 第15题:https://projecteuler.net/problem=15 ''' Project Euler: Problem 15: Lattice paths 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…
本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest product in a grid # In the 20×20 grid below, four numbers along a diagonal line have been marked in red. # The product of these numbers is 26 × 63 × 78 ×…
本题来自 Project Euler 第10题:https://projecteuler.net/problem=10 # Project Euler: Problem 10: Summation of primes # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. # Answer: 142913828922 def f(x):…
本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multiple # 2520 is the smallest number that can be divided by # each of the numbers from 1 to 10 without any remainder. # What is the smallest positive num…
本题来自 Project Euler 第3题:https://projecteuler.net/problem=3 # Project Euler: Problem 3: Largest prime factor # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? # Answer: 6857 a = 6008514751…
本题来自 Project Euler 第2题:https://projecteuler.net/problem=2 # Each new term in the Fibonacci sequence is generated # by adding the previous two terms. # By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By…
开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we list all the natural numbers below 10 # that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all…
题意:三个正整数a + b + c = 1000,a*a + b*b = c*c.求a*b*c. 解法:可以暴力枚举,但是也有数学方法. 首先,a,b,c中肯定有至少一个为偶数,否则和不可能为以上两个等式均不会成立.然后,不可能a,b为奇c为偶,否则a*a%4=1, b*b%4=1, 有(a*a+b*b) %4 = 2,而c*c%4 = 0.也就是说,a和b中至少有一个偶数. 这是勾股数的一个性质,a,b中至少有一个偶数. 然后,解决过程见下(来自project euler的讨论): tag:m…
Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger is in his class, and she is better than him at it.  Prime numbers are of mystical importance in Arithmancy, and Lucky Numbers even more so. Lucky Numbe…
In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentagonal number, I can only wonder if we have to deal with septagonal numbers in Problem 46. Anyway the problem reads Pentagonal numbers are generated by t…
题目要求是: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319…
Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger is in his class, and she is better than him at it. Prime numbers are of mystical importance in Arithmancy, and Lucky Numbers even more so. Lucky Number…
Project Euler: 欧拉计划是一系列挑战数学或者计算机编程问题,解决这些问题需要的不仅仅是数学功底. 启动这一项目的目的在于,为乐于探索的人提供一个钻研其他领域并且学习新知识的平台,将这一平台打造一个有趣和休闲 的环境. 项目主页:https://projecteuler.net 第一题 Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we ge…
本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names scores Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into al…
本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial digit sum n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! i…