- 浏览: 36872 次
- 性别:
- 来自: 杭州
最新评论
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 883package com.yao.Algorithms; ... -
Problem24
2012-04-26 14:12 783package com.yao.Algorithms; ... -
Problem23
2012-03-18 13:29 902A perfect number is a number fo ... -
Problem22
2012-03-17 23:13 769Using names.txt (right click an ... -
Problem21
2012-03-11 20:44 1204Problem 21 05 July 2002 Let ... -
Problem20
2011-12-15 14:09 803package com.yao.shuimu.euler; ... -
Problem19
2011-12-09 14:07 718package com.shui.mu.yao.io.algo ... -
Problem18/Problem67
2011-12-04 20:20 893package com.yao.Algorithms; ... -
Problem16
2011-12-02 15:32 417package com.shui.mu.yao.io.algo ... -
Problem15
2011-11-29 23:28 532package com.yao.Algorithms; ... -
Problem14
2011-11-29 11:37 706package com.shui.mu.yao.io.algo ... -
Problem13_1
2011-11-21 14:07 588package yao.taobao.jj; publi ... -
Problem13
2011-11-19 23:51 565package com.yao.Algorithms; ... -
Problem12
2011-11-07 20:04 710package com.shui.mu.yao.io.algo ... -
Problem11
2011-11-06 19:38 1195package com.yao.Algorithms; ... -
Problem10
2011-11-03 20:14 414package com.shui.mu.yao.io.algo ... -
Problem9
2011-11-03 16:04 747package com.shui.mu.yao.io.algo ... -
Problem8
2011-11-03 12:38 591package com.shui.mu.yao.io.algo ... -
Problem7
2011-11-03 11:25 456package 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, ...);
官方离线安装包,亲测可用
在本项目"0-1-knapsack-problem-master (26)c.zip"中,我们将会看到这个问题的C语言实现。 首先,我们需要理解0-1背包问题的基本概念。在这个问题中,我们有n个物品,每个物品i有一个重量wi和一个价值vi。背包有一...
0-1 背包问题(0-1 Knapsack Problem)是计算机科学中的一个经典优化问题,尤其在算法设计和分析领域具有重要的研究价值。它属于组合优化问题,经常出现在背包类问题、资源分配、投资策略等场景。在这个问题中,我们...
### 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 ...
说明:在最小化CentOS Linux release 7.6.1810 中制作yum源,docker-ce是centos 7系统x86架构rpm包。 使用: 1、上传文件到/data/docker-ce解压,或者任意目录后修改docker-ce-26.1.0.repo 中baseurl路径。...
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 ...