- 浏览: 37063 次
- 性别:
- 来自: 杭州
最新评论
package com.shui.mu.yao.io.algorithm; public class Problem14 { public static void main(String[] args) { long starttime = System.currentTimeMillis(); int start = 640000;/**10:123456789往上翻20再翻40..->640000--1280000*/ int end = 1000000; int[] seed = new int[end]; int max = 0; int digit = 0; /**预热10W数据到arr里面 存储seed值*/ for (int i = 2; i < 10000; i++) { find(end, seed, i); } for (int i = start; i < end; i++) { int number=find(end, seed, i); if (number > max) { max = number; digit = i; } } System.out.println("digit: "+digit+"\t"+"maxCount:"+max); System.out.println(System.currentTimeMillis() - starttime); } private static int find(int end, int[] seed, int i) { long count = i; int number = 0; if(seed[i]>0) return seed[i]; while (count != 1) { if(count<end&&seed[(int) count]>0) { number+=seed[(int) count]; break; } if ((count & 0X0001) == 0) { count = count >> 1; } else { count = (count << 1) + 1 + count; } number++; } seed[i]=number; return number; } }
发表评论
-
Problem26
2013-02-06 17:08 870A unit fraction contains 1 in t ... -
Problem25
2012-04-26 16:33 888package com.yao.Algorithms; ... -
Problem24
2012-04-26 14:12 788package com.yao.Algorithms; ... -
Problem23
2012-03-18 13:29 907A perfect number is a number fo ... -
Problem22
2012-03-17 23:13 776Using names.txt (right click an ... -
Problem21
2012-03-11 20:44 1209Problem 21 05 July 2002 Let ... -
Problem20
2011-12-15 14:09 810package com.yao.shuimu.euler; ... -
Problem19
2011-12-09 14:07 721package com.shui.mu.yao.io.algo ... -
Problem18/Problem67
2011-12-04 20:20 902package com.yao.Algorithms; ... -
Problem16
2011-12-02 15:32 424package com.shui.mu.yao.io.algo ... -
Problem15
2011-11-29 23:28 539package com.yao.Algorithms; ... -
Problem13_1
2011-11-21 14:07 594package yao.taobao.jj; publi ... -
Problem13
2011-11-19 23:51 573package com.yao.Algorithms; ... -
Problem12
2011-11-07 20:04 714package com.shui.mu.yao.io.algo ... -
Problem11
2011-11-06 19:38 1203package com.yao.Algorithms; ... -
Problem10
2011-11-03 20:14 417package com.shui.mu.yao.io.algo ... -
Problem9
2011-11-03 16:04 755package com.shui.mu.yao.io.algo ... -
Problem8
2011-11-03 12:38 594package com.shui.mu.yao.io.algo ... -
Problem7
2011-11-03 11:25 461package com.shui.mu.yao.io.algo ...
相关推荐
14. 主键的建立方法:三种(Problem 14) 主键可以使用 PRIMARY KEY 约束、UNIQUE 约束或索引来建立。 15. 视图上的限制操作:不能定义新的基本表(Problem 15) 视图是一个基于表的虚拟表,不能在视图上定义新的...
14. **Problem 14: 长链回文子串** - 知识点:字符串处理,回文判断,循环结构。 - 解决方法:计算每个数的回文子串长度,找到最长的那个。 通过解决这些问题,你可以掌握R语言的基本语法、数据类型、控制流、...
Chapter 14. Web-Based Problem Solving Process Chapter 15. Software Tool Development Illustration Chapter 16. Software Tools for Correct Program Development Part 5 Computer Operation by Problem ...
13.Algorithm Gossip: 背包问题(Knapsack Problem 14.Algorithm Gossip: 蒙地卡罗法求 PI 15.Algorithm Gossip: Eratosthenes 筛选求质数 16.Algorithm Gossip: 超长整数运算(大数运算). 17.Algorithm Gossip: 长...
14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying ...
《C++ Programming From Problem Analysis to Program Design 8th》是一本深入浅出的C++编程教程,由资深计算机教育家Zelle撰写。该书旨在帮助读者从问题分析到程序设计的整个过程,全面掌握C++语言。最新版更新至...
13. 成为问题的原因 - Become a problem 14. 担忧时间 - Worry about time 15. 陷入困境 - Get into trouble 16. 允许某人做某事 - Allow sb. to do sth. 17. 对某人要求严格 - Be strict with sb. 18. 在外呆的很迟...
在实现算法时,需要注意效率,因为题目允许的时间限制是14秒(对于Java等非C++语言是7秒),内存限制是512MB。因此,需要优化算法,避免不必要的计算和空间浪费。可以考虑使用高效的数据结构和优化的合并策略,如...
14 Map Coloring & Chromatic Number......Page 271 iLLusTrATinG The TheOrem......Page 273 eArLy ATTemPTs AT PrOOf......Page 275 summAry Of evenTs ThAT LeD TO The DefiniTiOn AnD sOLuTiOn TO The fOur ...
Benny Kjr Nielsen and Allan Odgaard fbenny, dug@diku.dk February 14, 2003 The main subject of this thesis is the so-called nesting problem, which (in short) is the problem of packing arbitrary two-...
机器学习基石10 - 1 - Logistic Regression Problem (14-33).mp4
int M, g, a[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, ag[20], c[20]; ``` - 初始化数组`a`,用于存储可能填入环中的数字。 - `ag`数组用于标记数字是否已被使用。 - `c`...
#### 第14章:递归与栈(p.801) 递归是一种强大的编程技术,可以简化许多算法的设计。本节解释了递归的基本原理以及如何使用递归函数。 - **递归**:函数调用自身的过程。 - **递归基**:递归终止条件,确保递归...
#### Chapter 14: Recursion This chapter introduces recursion, a powerful programming technique: - **Recursive Functions**: Explanation of recursive functions, including base cases and recursive ...
Chapter 14. Exception Handling. Chapter 15. Recursion. Chapter 16. Searching and Sorting. Chapter 17. Linked Lists. Chapter 18. Stacks and Queues. Appendix A. Reserved Words. Appendix B. Operator ...
by the standard IEEE benchmark systems with 14, 30, 57, 118, and 300 buses as well as several randomly generated systems. Since this condition is hard to study, a sufficient zero-duality-gap condition...
CHAPTER 14: STRING ALGORITHMS CHAPTER 15: ALGORITHM DESIGN TECHNIQUES CHAPTER 16: BRUTE FORCE ALGORITHM CHAPTER 17: GREEDY ALGORITHM CHAPTER 18: DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER CHAPTER 19: ...
#### 第14章:递归与栈 - **递归与栈**:讲解了递归的基本原理以及递归函数如何使用调用栈来保存状态。同时介绍了递归算法的设计方法及其应用案例。 #### 第15章:继承示例 - **继承**:通过具体例子展示了如何...