`
水木清华77
  • 浏览: 36241 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Problem12

阅读更多
package com.shui.mu.yao.io.algorithm;

import java.util.ArrayList;
import java.util.List;

public class Problem12 {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int x = 500;
		int count = 1;
		while ((x /= 2) != 0) {
			count++;
		}
		List<Integer> seed = new ArrayList<Integer>();
		seed.add(2);
		int factor = 2;
		while (seed.size() < 500) {
			boolean isPrime = true;
			for (int s : seed) {
				if (factor < s)
					break;
				if (factor % s == 0)
					isPrime = false;
			}
			if (isPrime)
				seed.add(factor);
			factor++;
		}

		int N = (int) Math.pow(2, count);
		int sum = 0;
		List<Node> list = new ArrayList<Node>();
		while (true) {
			N++;
			sum = (1 + N) / 2 * N;
			list.clear();
			for (int s : seed) {
				if (sum < s)
					break;
				int count_ = 0;
				int temp = sum;
				while (temp % s == 0) {
					count_++;
					temp = temp / s;
				}
				if (count_ != 0) {
					list.add(new Node(s, count_));
				}

			}
			int result = 1;
			for (Node node : list) {
				result = result * (node.getY() + 1);
			}
			if (result > 500) {
				int re=1;
				for (Node node : list) {
					System.out.println("factor:" + node.getX() + "\t"
							+ "count:" + node.getX());
					re*=Math.pow(node.getX(), node.getY());
				}
				if(re==sum)
					System.out.println("this is a true result");
				System.out.println("sum:" + sum);
				System.out.println("N:" + N);
				break;
			}

		}

		long end = System.currentTimeMillis();
		System.out.println("time:" + (end - start) + "ms");

	}

}

class Node {
	private int x;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	private int y;

	Node(int x, int y) {
		this.x = x;
		this.y = y;
	}
}
分享到:
评论

相关推荐

    单峰测试函数:Axis、Quadric、Rosenbrock、SchwefelProblem12、SchwefelProblem22、SumSquar、Step

    类似于Schwefel's Problem 12,Schwefel's Problem 22也是Schwefel函数系列的一部分,用于评估优化算法在处理复杂多峰函数时的表现。它的最小值可能分布在不同的区域,挑战算法的全局探索能力。 6. **SumSquar(和...

    爱立信CSR数据采集规范

    12. DTI problem 8 13. Group Switch problem 8 14. IN problem 9 15. ONE WAY SPEECH 9 16. CALL WAITING 9 17. Location Update problem 10 18. Cannot make/receive call, send/receive SMS 10 19. CP Overload ...

    Computer-Based.Problem.Solving.Process

    Chapter 12. Computation Activity and Its Management Tools Part 4 Software Tools Supporting Program Development Chapter 13. Problem Solving by Software Tools Chapter 14. Web-Based Problem Solving ...

    Problem Solving with C++, 10th Global Edition

    Problem Solving with C++, Global Edition by Walter Savitch (author) (Author) Pages:1117 出版社: Pearson Education Limited; 10th edition edition (November 20, 2017) Language: English ISBN-10: ...

    Wicked Problem

    ### Wicked Problem与Wicked Environmental Problem #### 一、引言 "Wicked Problem"(棘手问题)这一概念最初由霍恩(Horst Rittel)和韦伯(Melvin Webber)于1973年提出,指的是那些复杂且难以解决的问题。这类...

    node-problem-detector-0.8.7.tar

    node-problem-detector 镜像包 v0.8.7 版本

    MCM 2012 problem A B C 论文

    MCM 2012年 problem A problem B problem C 枪手论文

    MySQL数据库考试试题.docx

    12. 事务处理命令:COMMIT 语句(Problem 12) COMMIT 语句用于将事务处理写到数据库中。 13. 条件语句:WHERE 子句(Problem 13) WHERE 子句用于指定 SELECT 语句的条件,以便仅检索满足条件的数据。 14. 主键...

    Problem Arrangement zoj 3777

    Problem Arrangement zoj 3777

    problem

    标题 "problem" 提供的信息较少,但从描述中的 "NULL 博文链接:https://eric0000.iteye.com/blog/322311" 可以推测,这可能是一个关于解决某个问题或者技术讨论的博客文章链接。由于没有具体的博文内容,我们无法...

    台大机器学习作业六1

    **Problem 12**:介绍了逐步增强法(Boosting),特别是AdaBoost算法,这是一种集成学习方法,通过迭代和加权训练弱分类器,构建强分类器。 这些题目覆盖了机器学习中的基础概念,包括优化、核方法、概率统计、...

    算法设计taxi problem

    算法设计里关于taxi problem的C语言代码

    Problem_C_Data.zip

    "Problem_C_Data.zip" 是一个压缩包文件,包含2020年美国数学建模竞赛(简称美赛)C题的题目及相应的原始数据。美赛是一项国际性的数学建模竞赛,每年吸引众多学生参与,旨在提升参赛者的数学、数据分析和解决实际...

    euler project.r.zip_R Euler project_project

    12. **Problem 12: 三角形数的倍数** - 知识点:三角形数计算,循环结构,计数。 - 解决方法:计算三角形数,直到找到第一个有超过500个因数的数。 13. **Problem 13: 大数显示** - 知识点:大数处理,字符串...

    master page search problem

    在这个特定的问题“master page search problem”中,我们可能遇到的是在使用Master Page时搜索功能出现的问题。ViewData是ASP.NET MVC框架中的一个特性,用于在控制器和视图之间传递数据,而JavaScript则是客户端...

    Problem 1002

    HDOJ Problem 1001 C++版

    machine problem

    在操作系统课程中,"机器问题"(Machine Problem)通常指的是与计算机硬件、系统架构以及操作系统内核相关的复杂问题。这些问题涉及到资源管理、并发控制、进程调度、内存分配等多个核心概念,是理解操作系统工作...

    flow shop problem GA算法

    flow shop problem GA算法 详细代码标注

    《Approaching (Almost) Any Machine Learning Problem》

    Approaching (Almost) Any Machine Learning Problem是一本旨在帮助读者掌握机器学习问题解决方法的书籍。这本书涵盖了机器学习的基本概念、模型选择、数据预处理、特征工程、模型评估等多方面的知识点。 机器学习...

    problem with

    《ThinkPad 中遇到的未授权 MiniPCI 网络卡问题及解决方案》 在使用ThinkPad笔记本电脑时,用户可能会遇到一个棘手的问题——“未经授权的网络卡已插入”。这通常发生在尝试使用非官方或非认证的MiniPCI(Express)...

Global site tag (gtag.js) - Google Analytics