题目链接 Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; class level57{ void solve0(){ /*** a a+2b --- ------- b a+b ***/ int count = 0; BigInteger a=BigInteger.va…
It is possible to show that the square root of two can be expressed as an infinite continued fraction.  2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.51 + 1/(2 + 1/2) = 7…
题目链接 欧拉函数φ(n)(有时也叫做phi函数)可以用来计算小于n 的数字中与n互质的数字的个数. 当n小于1,000,000时候,n/φ(n)最大值时候的n. 欧拉函数维基百科链接 这里的是p是n的素因子,当素因子有相同的时候只取一个 任意一个正整数都能分解成若干个素数乘积的形式 如下所示: long phi(int n){ long res=0; int pi=0; if(n==1) return 0; res = n; pi = 2; while(n!=1){ if(n%pi==0){…
题目链接 和上面几题差不多的 Euler's Totient function, φ(n) [sometimes called the phi function]:小于等于n的数并且和n是互质的数的个数 存在这样的数:N的欧拉数φ(n),是N的一个排列 例如:φ(87109)=79180 求在1---10^7中n/φ(n) 取到最小的 n 是多少? 这里的是p是n的素因子,当素因子有相同的时候只取一个 任意一个正整数都能分解成若干个素数乘积的形式 直接利用上题的phi函数就可以求解 这个是跑的最…
题目链接 找循环位数是奇数的数有多少个 这个自己很难写出来,完全不能暴力 维基百科链接 维基百科上面说的很好,上面的算法实现就好了. 就是上面的 Java程序: package project61; public class P64{ void run(){ int count = 0; int m = 0; int d = 1; int a0 = 0; int a = 0; int period = 0; for(int S = 2;S<10000;S++){ period = 0; m =…
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…
题目链接 脑补知识:佩尔方差 上面说的貌似很明白,最小的i,对应最小的解 然而我理解成,一个循环的解了,然后就是搞不对,后来,仔细看+手工推导发现了问题.i从0开始变量,知道第一个满足等式的解就是最小解. 问题转化为求根号n的连分数问题,分子就是x,分母就是y 要求的分子,分母,问题又转化为:根号n的连分数表示,对,求出其连分数表示就OK了 先求出a的序列是什么? 第64题,就是求a的序列的. a求出来了,要求出分子分母的表达式. 第65题,就是已经知道了a的序列,求分子,当然也可以求分母的 分…
题目链接 现在做这个题目真是千万只草泥马在心中路过 这个与上面一题差不多 这个题目是求e的第100个分数表达式中分子的各位数之和 What is most surprising is that the important mathematical constant,e = [2; 1,2,1, 1,4,1, 1,6,1 , ... , 1,2k,1, ...]. The first ten terms in the sequence of convergents for e are: 2, 3,…
---恢复内容开始--- 题目链接 从三角数开始,循环到八角数,再到三角数,求这6个数的和 这个比较复杂,代码在网上找的 Java: package project61; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import jav…
题目链接   Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; class level56{ void solve0(){ int maxsum=0; for(int a=2;a<100;a++){ for(int b=2;b<100;b++){ BigInteger…
package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; class level55{ void solve0(){ int Max=10000; int count=0; for(int i=0;i<Max;i++){ if(isLychrel(i)) count++; } System.o…
package projecteuler51to60; import java.awt.peer.SystemTrayPeer; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.TreeSet; class Card{ //…
package projecteuler51to60; class p53{ void solve1(){ int count=0; int Max=1000000; int[][] table=new int[101][101]; for(int row=0;row<=100;row++){ table[row][0]=table[row][row]=1; for(int col=1;col<=row-1;++col){ table[row][col]=table[row-1][col]+t…
题目链接 题目: 125874和它的二倍,251748, 包含着同样的数字,只是顺序不同. 找出最小的正整数x,使得 2x, 3x, 4x, 5x, 和6x都包含同样的数字. 这个题目相对比较简单 暴力遍历 判断x,2x,3x,4x,5x,6x是否包含的数字相同 如何判断两个数包含的数字相同? 1. 两个数字转换成字符串后:d1,d2 定义两个集合ts1,ts2, 将d1,d2的各位数都添加到集合ts1中 将d1的各位数添加到集合ts2中 最后这个两个集合相等,则,这个两个数包含相同的数字 2.…
题目链接 题目: 通过置换*3的第一位得到的9个数中,有六个是质数:13,23,43,53,73和83. 通过用同样的数字置换56**3的第三位和第四位,这个五位数是第一个能够得到七个质数的数字,得到的质数是:56003, 56113, 56333, 56443, 56663, 56773, 和 56993.因此其中最小的56003就是具有这个性质的最小的质数. 找出最小的质数,通过用同样的数字置换其中的一部分(不一定是相邻的部分),能够得到八个质数. 解题思想: 这个题目是很难的 你首先要找到…
题目链接:https://projecteuler.net/problem=72 真分数;n/d 当d ≤ 1,000,000时候的真分数有多少个 public class P72{ void run(){ int max_n = 1000000; long[] phi = cal_phi(max_n+1); long sum=0; phi[1] = 0; for(int i =1;i<=max_n;i++) sum+=phi[i]; System.out.println(sum); } //…
题目链接:https://projecteuler.net/problem=71 If n<d and HCF(n,d)=1, it is called a reduced proper fraction. n/d 真分数升序排序后,离 3/7最近的数,d<=1000000 Java程序: public class P71{ void run(){ calculate(); } void calculate(){ int max_n = 1000000; long a = 3; long b…
题目链接 任意一条线上的三个数的和都等于9,顺时针,从最小的外圈开始,得到的序列是:432621213 和             序列 9位的字符串:三角环所能形成的最大字符串为432621513. 使用数字1到10,通过不同的安排,可以得到16位或17位的字符串.五角环所能形成的最大的16位的字符串是什么? 16位的字符,10在外圈 17位的字符,10在内圈 求最大的字符串 6,7,8,9,10应该在外圈,1,2,3,4,5在内圈 2*(1+2+3+4+5) +6+7+8+9+10 = 70…
题目链接 The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power. How many n-digit positive integers exist which are also an nth power? 这个题目有点坑: 先说自己的思路<虽然方法不是很好> 根据题意可知道: a的b次方 除以 最小的b位数(如:1,10…
题目链接 找出最小的立方数,它的各位数的排列能够形成五个立方数 解决关键点: 这五个数的由相同的数组成的 可以用HashMap,Key是由各位数字形成的key,value记录由这几个数组成的立方数出现的次数 Key如何确定? 1.这个数的每位数排序后,(升序或降序),重新组成的数当作Key 2.根据该数0-9,出现的次数,组成的字符串当作Key Java程序: package project61; import java.util.HashMap; public class P62{ long…
题目链接 五个数,任意两个数的任意链接后的数还是质数 满足这个条件的最小五个数的和是多少? 结果:26033 纯暴力破解: package projecteuler51to60; import java.util.ArrayList; import java.util.List; import java.util.TreeSet; class level60{ void solve1(){ List<Integer> primes = new ArrayList<>(); int…
题目链接 Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; class level58{ void solve0(){ /*** i = 1 (2i-1)^2-4(i-1) (2i-1)^2-6(i-1) ---------------- ----------------…
题目链接:https://projecteuler.net/problem=74 数字145有一个著名的性质:其所有位上数字的阶乘和等于它本身. 1! + 4! + 5! = 1 + 24 + 120 = 145 169不像145那么有名,但是169可以产生最长的能够连接回它自己的数字链.事实证明一共有三条这样的链: 169 --> 363601 -->  1454 -->  169871 -->  45361 -->  871872 -->  45362 -->…
题目链接:https://projecteuler.net/problem=73 n/d的真分数 ,当d<=12000时 在 1/3 and 1/2 之间的有多少个 public class P73{ void run(){ FareySequences(); } void FareySequences(){ int limit = 12000; int a = 1; int b = 3; int c = 4000; int d = 11999; int count=0; while(!(c==…
五十七.平方根收敛(Square root convergents) 二的平方根可以表示为以下这个无穷连分数: \[ \sqrt 2 =1+ \frac 1 {2+ \frac 1 {2 +\frac 1 {2+ \dots}}} \] 通过把前四项展开,我们得到: \[ \begin{aligned}1 + \frac 1 2 &= \frac 32 = 1.5\\1 + \frac 1 {2 + \frac 1 2} &= \frac 7 5 = 1.4\\1 + \frac 1 {2…
该题没思路,参考了网上各种题解.... 注意到凡是那种11111..... 22222..... 33333.....之类的序列都可用这个式子来表示:k*(10^x-1)/9进而简化:8 * (10^x-1)/9=L * k (k是一个整数)8*(10^x-1)=9L*kd=gcd(9L,8)=gcd(8,L)8*(10^x-1)/d=9L/d*k令p=8/d q=9L/d p*(10^x-1)=q*k因为p,q互质,所以q|(10^x-1),即10^x-1=0(mod q),也就是10^x=1…
GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1997    Accepted Submission(s): 772 Problem Description Do you have spent some time to think and try to solve those unsolved problem aft…
先做个说明,里面所有的题都是我自己写的解题报告,由于我的能力有限,是个刚学java的小白,有很多不足的地方,还望各位大佬不奢赐教,谢谢! Largest product in a grid In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08           …
http://acm.nyist.net/JudgeOnline/problem.php?pid=42题目链接 #include <cstdio> #include <cstring> #define CLR(arr) memset(arr,0,sizeof(arr)) #define P 1001 int G[P],fa[P]; int find(int x){return x==fa[x]?x:x=find(fa[x]);} int main() {     int n,a,b…
<题目链接> 题目大意: Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that a = xy and b = xz. 解题分析: 其实只要看懂题目就会…