- 浏览: 37221 次
- 性别:
- 来自: 杭州
最新评论
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:
1/2 = 0.5
1/3 = 0.(3)
1/4 = 0.25
1/5 = 0.2
1/6 = 0.1(6)
1/7 = 0.(142857)
1/8 = 0.125
1/9 = 0.(1)
1/10 = 0.1
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.
Find the value of d 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
1/2 = 0.5
1/3 = 0.(3)
1/4 = 0.25
1/5 = 0.2
1/6 = 0.1(6)
1/7 = 0.(142857)
1/8 = 0.125
1/9 = 0.(1)
1/10 = 0.1
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.
Find the value of d 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
package euler; import java.util.HashSet; import java.util.Set; /** * * @author hongfa.yy * @version 2013-2-6 下午4:48:51 */ public class Problem26 { public static void main(String[] args) { int max = 0; int max_d=0; for (int i = 1; i < 1000; i++) { int count = count(i); if (count > max){ max_d=i; max = count; } } System.out.println(max_d); } private final static int decimalism = 10; private static int count(int denominator) { Set<Integer> set = new HashSet<>(); int mode = 1 * decimalism % denominator; while (mode != 0) { if (!set.contains(mode)) set.add(mode); else return set.size(); mode = mode * decimalism % denominator; } return 0; } }
发表评论
-
Problem25
2012-04-26 16:33 889package com.yao.Algorithms; ... -
Problem24
2012-04-26 14:12 789package com.yao.Algorithms; ... -
Problem23
2012-03-18 13:29 910A perfect number is a number fo ... -
Problem22
2012-03-17 23:13 779Using names.txt (right click an ... -
Problem21
2012-03-11 20:44 1216Problem 21 05 July 2002 Let ... -
Problem20
2011-12-15 14:09 815package com.yao.shuimu.euler; ... -
Problem19
2011-12-09 14:07 725package com.shui.mu.yao.io.algo ... -
Problem18/Problem67
2011-12-04 20:20 906package com.yao.Algorithms; ... -
Problem16
2011-12-02 15:32 427package com.shui.mu.yao.io.algo ... -
Problem15
2011-11-29 23:28 545package com.yao.Algorithms; ... -
Problem14
2011-11-29 11:37 720package com.shui.mu.yao.io.algo ... -
Problem13_1
2011-11-21 14:07 599package yao.taobao.jj; publi ... -
Problem13
2011-11-19 23:51 578package com.yao.Algorithms; ... -
Problem12
2011-11-07 20:04 715package com.shui.mu.yao.io.algo ... -
Problem11
2011-11-06 19:38 1205package com.yao.Algorithms; ... -
Problem10
2011-11-03 20:14 424package com.shui.mu.yao.io.algo ... -
Problem9
2011-11-03 16:04 760package com.shui.mu.yao.io.algo ... -
Problem8
2011-11-03 12:38 598package com.shui.mu.yao.io.algo ... -
Problem7
2011-11-03 11:25 469package com.shui.mu.yao.io.algo ...
相关推荐
26. a) Virus Requires some form of human interaction to spread. Classic example: E-mail viruses. b) Worms No user replication needed. Worm in infected host scans IP addresses and port numbers, ...
MySQL数据库考试试题 以下是根据提供的文件信息生成的相关知识点: ...26. 创建表语句:CREATE TABLE 语句(Problem 26) CREATE TABLE 语句用于创建一个新的表,例如 CREATE TABLE SC (S# CHAR, ...);
官方离线安装包,亲测可用
### Ulam's Problem:在没有反馈的情况下搜索与说谎者博弈 #### 一、问题背景与定义 Ulam的问题起源于斯坦尼斯拉夫·乌拉姆(Stanislaw Ulam)提出的一个智力游戏,该问题涉及到如何在面对可能的谎言回答时确定一...
在这个压缩包中,包含了26个测试函数,这些函数是为评估和比较优化算法性能而设计的。MATLAB用户经常使用这样的测试集来验证自定义优化算法的有效性,或者对比内置优化工具箱的功能。 "benchmark_func.m"很可能是主...
Delphi VCLSkin 5.30 ... VCLSkin is a component to create skinnable user interface for Delphi/C++Builder application, It is easy to use, just put one component on mainform, ...* fix caption paint problem...
leetcode 不会问题解决-LeetCode 破解代码面试: ...26 for i in range ( len ( astr )): index = ord ( astr [ i ]) - ord ( 'a' ) if arr [ index ] == 1 : return False else : arr [ index ] += 1 return T
26; 41; 58i, a sorting algorithm returns as output the sequence h26; 31; 41; 41; 58; 59i. Such an input sequence is called an instance of the sorting problem. In general, an instance of a problem ...
- [题目26](http://acm.pku.edu.cn/JudgeOnline/problem?id=2449) —— 可重复K最短路,A*搜索。 - [题目27](http://acm.pku.edu.cn/JudgeOnline/problem?id=1190) —— 深度优先搜索剪枝。 - [题目28]...
Volume 26, January 1989 INTERPERSONAL PROBLEM SOLVING AND CHILDREN’S SOCIAL COMPETENCE: ARE CURRENT MEASURES VALID?’ C . JULIUS MEISEL University of Delaware Ninety-four first- and second-...
monographs are devoted to the subject [34, 26]. Since the TSP is NP-hard, polynomial-time approximation algorithms are usually studied. However, usually the approaches to the study of vehicle routing ...
26.06.2008 AlphaControls v5.50 stable released * TsNotebook component was completely changed * Many small improvements 18.06.2008 AlphaControls v5.49 stable released * Solved problem of MDI ...
1.00.2160 (October 26, 2004) Added option to prevent modem control signals following legacy port behaviour at startup. 1.00.2159 (October 15, 2004) Fixed delay on disconnect under WinXP. 1.00....
2012 | ISBN-10: 1617290238 | PDF, EPUB | 536 pages | 26 + 37 MB Hadoop in Practice collects 85 Hadoop examples and presents them in a problem/solution format. Each technique addresses a specific ...
Aversiveness of teacher-chosen interventions and student problem characteristics: Is there a relationship? Fragile X Syndrome 389 WECHSLER, D. (1958). The measurement and appraisal of adult ...
A Layer 1 problem exists**:这表明可能存在的问题是物理层的问题,如连接线缆、端口故障等。 - **B. The bandwidth is set too low**:带宽设置得过低通常不会导致接口状态显示为down。 - **C. A protocol ...
26 6 23 关联 7 27 关联 8 112 关联 9 104 10 167 关联 11 21 12 121 13 53 14 35 15 122 16 110 17 257 18 637 19 242 20 252 中等的 问题 力码# 解决方案 1 2 关联 2 3 3 12 关联 4 34 5 92 关联 6 1249 7 142 8 ...
tsp问题matlab代码步骤...US26.dat:在美国随机选择的26个州首府的坐标 tourmap_48.png:48个城市游览的地块 tourmap_26.png:26个城市游览的地块 US48TourPlot.m:Matlab代码以绘制使用Mosel代码生成的48个城市游览 US