Difference between revisions of "Project Euler"
Jump to navigation
Jump to search
Xiejiadong (talk | contribs) |
Xiejiadong (talk | contribs) |
||
Line 14: | Line 14: | ||
== Problem 2 == | == Problem 2 == | ||
+ | |||
+ | == Problem 35 == | ||
+ | |||
+ | === Circular primes === | ||
+ | |||
+ | Solved by Xiejiadong. | ||
+ | |||
+ | 题意:求$10^6$以下循环串组成的数都是质数的数的个数。 | ||
+ | |||
+ | 题解:先把质数用筛选法筛出来,然后暴力枚举判断,时间复杂度$O(6*10^6)$。 | ||
+ | |||
+ | 答案:55 | ||
== Problem 36 == | == Problem 36 == |
Revision as of 04:32, 21 December 2018
挖了一个大坑,天知道什么时候能填完。感觉是不可能填完的。
Problem 1
Multiples of 3 and 5
Solved by Xiejiadong & Czarina.
题意:$1000$以下约数包含$3$和$5$的数和。
题解:直接暴力/等差数列求和。
答案:233168。
Problem 2
Problem 35
Circular primes
Solved by Xiejiadong.
题意:求$10^6$以下循环串组成的数都是质数的数的个数。
题解:先把质数用筛选法筛出来,然后暴力枚举判断,时间复杂度$O(6*10^6)$。
答案:55
Problem 36
Double-base palindromes
Solved by Xiejiadong.
题意:求$10^6$以下满足十进制和二进制都是回文数的所有数和。
题解:枚举二进制的长度,dfs暴力所有的二进制数,再判断十进制数是否符合题意。
为了防止重复,我们要在制定二进制的长度以后,默认第一位必须是$1$。
这样做的复杂度会比直接判断的小一些。
答案:872187。