题目: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten…
题目: 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 number that is evenly divisible by all of the numbers from 1 to 20? 此题就是求最小公倍数的,刚开始我考虑的太复杂,打算求出每个数的素数因子,然后去处一…
题目: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc. 代码: 1 #include<iostream…
题目: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586156078911294949545950173795833195285320…
题目:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number? 方法一: 1 #include<iostream> 2 using namespace std; 3 bool isPrime(long long num); 4 int main() { 5 int count = 1;…
1 //题目:The prime factors of 13195 are 5, 7, 13 and 29. 2 //What is the largest prime factor of the number 600851475143 ? 1 #include<iostream> 2 using namespace std; 3 int main() { 4 long long N = 600851475143;//int和long都为32位,long long 为64位 5 int i;…
继续做题-经过py3测试 原题链接:http://www.runoob.com/python/python-exercise-example6.html 题目:斐波那契数列. 我的代码: def fib(n): if n==1: l=[0] elif n==2: l=[0,1] else: l=[0,1] for i in range(2,n): l.append(l[i-1]+l[i-2]) return l 思考:函数fib是以列表的形式返回的斐波那契数列,该列表第0/1位的无法迭代得出,所…
package com.android; public class SpiralPrimes { public static void main(String args[]) { long numPrimes = 0; long numAll = 0; long oneStart = 1; for (long i = 3; i < Long.MAX_VALUE; i = i + 2) { numAll = 2*i-1; if(isPrimes(i*i)){ numPrimes++; } if(i…
Multiples of 3 and 5 原题 题意如下: 找出N以内的3和5的倍数的和. 思路 1.刚看到觉得好弱智,直接遍历一遍不就OK了吗?但是第2和第3个测试用例报了TLE,超时. 2.然后想不出来了,搜了一下,发现有一个类似的题计算1000以内的3和5的倍数的和,用的是算出3的倍数的和加上5的倍数的和减去15的倍数的和,因为是直接计算所以不需要遍历,自然就快了.按照同样的思路,可以找到小于N的最大的3的倍数,5的倍数和15的倍数. 代码 int main(){ int t; cin >…
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. 37 42 4 68 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom in triangle.txt (right c…
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…