`
to_zoe_yang
  • 浏览: 143328 次
  • 性别: Icon_minigender_2
  • 来自: 01
社区版块
存档分类
最新评论

Problem 33

 
阅读更多

问题描述:

The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.

We shall consider fractions like, 30/50 = 3/5, to be trivial examples.

There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.

If the product of these four fractions is given in its lowest common terms, find the value of the denominator.

 

解决问题:

 

 

public static int find(){
		int result =0;
		int[][] numbers = new int[4][2];
		
		int fenzi = 11;
		int index = 0;
		for(fenzi=11; fenzi<100&&index<4; fenzi++){
			if(fenzi%10==0){
				continue;
			}else{
				for(int fenmu = fenzi+1; fenmu<100&&index!=4; fenmu++){
					int[] element = new int[4];
					element[0] = fenzi/10;
					element[1] = fenzi%10;
					element[2] = fenmu/10;
					element[3] = fenmu%10;
					//System.out.println(fenzi+":"+fenmu);
					if(element[0]==element[2]){
						if(fenzi*element[3]==fenmu*element[1]){
							numbers[index][0] = element[1];
							numbers[index][1] = element[3];
							index++;
							break;
						}
					}
					if(element[0]==element[3]){
						if(fenzi*element[2]==fenmu*element[1]){
							numbers[index][0] = element[1];
							numbers[index][1] = element[2];
							index++;
							break;
						}
					}
					if(element[1]==element[2]){
						if(fenzi*element[3]==fenmu*element[0]){
							numbers[index][0] = element[0];
							numbers[index][1] = element[3];
							index++;
							break;
						}
					}
					if(element[1]==element[3]){
						if(fenzi*element[2]==fenmu*element[0]){
							numbers[index][0] = element[0];
							numbers[index][1] = element[2];
							index++;
							break;
						}
					}
				}
			}
		}
		
		fenzi = 1;
		int fenmu = 1;
		for(int i=0; i<numbers.length; i++){
			fenzi *= numbers[i][0];
			fenmu *= numbers[i][1];
		}
		
		if(fenmu%fenzi==0){
			result = fenmu/fenzi;
		}else{
			
		}
		
		return result;
	}

 

分享到:
评论

相关推荐

    计算机网络第六版答案

    Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 ...This document contains the solutions to review questions ...Problem 1 There...

    Artificial Intelligence and Problem Solving

    PrOBLem-sOLvinG Techniques......Page 33 humAn WinDOW......Page 44 humAn WinDOW criTeriA & rAnkinG Of sOLuTiOns......Page 47 cLAssificATiOn......Page 50 Refs......Page 52 3 Missionaries & Cannibals.......

    机器学习基石10 - 1 - Logistic Regression Problem (14-33).mp4

    机器学习基石10 - 1 - Logistic Regression Problem (14-33).mp4

    爱立信CSR数据采集规范

    6. OMS statistics problem 6 7. HLR redundancy problem 6 8. MRBT related problem 7 9. USSD related problem 7 10. Announcement problem 7 11. Echo canceller (ECP) problem 8 12. DTI problem 8 13. Group ...

    C#,电话数字键盘问题(Mobile Numeric Keypad problem)的算法与源代码

    C#,电话数字键盘问题(Mobile Numeric Keypad problem)的算法与源代码 电话数字键盘问题 提供移动数字键盘。您只能按向上、向左、向右或向下至当前按钮的按钮。不允许您按最下面一行的角点按钮(即.*和#)。 ...

    Ant Colony Algorithm for Solving QoS Routing Problem

    ### Ant Colony Algorithm for Solving QoS Routing Problem #### 摘要与背景介绍 随着网络技术的不断发展,服务质量(Quality of Service, QoS)成为衡量网络性能的重要指标之一。QoS涉及延迟、抖动、带宽、丢包率...

    rand03.6.rar_33 bus ieee_DG on matlab_GA DG_optimal bus_optimal

    To solve this combinatorial problem, an algorithm known as Firefly algorithm is proposed in this paper. This is a meta-heuristic algorithm inspired by the behavior of fireflies flashing. The main ...

    Git in Practice(Manning,2014)

    Then, you'll dig into cookbook-style techniques like history visualization, advanced branching and rewriting history each presented in a problem-solution-discussion format. Finally you'll work out ...

    33届ACM杭州区域赛

    每个文件名如"Problem - 1010.mht"代表一个独立的问题,数字部分(如1010)可能是题目编号,而.mht文件格式通常用于存储HTML电子邮件或者单一文件网页,因此这些文件很可能包含了题目的详细描述、输入输出格式、样例...

    新概念英语第二册Lesson33 课件PPT课件.pptx

    "新概念英语第二册Lesson33 课件PPT课件.pptx" 本资源是一个英语学习课件,涵盖了多个英语单词和语法知识点。下面是从该资源中提炼出的知识点: 1. Darkness(黑暗):该词可以用来形容环境的黑暗,也可以用来形容...

    六年级英语Lesson 33 ~ Lesson 36 , Revision人教四年制知识精讲.doc

    在小学六年级英语课程中,Lesson 33 到 Lesson 36 及Revision部分,学生需要掌握一系列关键的词汇和表达方式。这些知识点对于提升学生的语言能力至关重要,特别是对于人教四年制的小学英语教育体系。 首先,"learn...

    基于禁忌搜索的33个城市TSP问题(c++)

    旅行商问题(Traveling Salesman Problem,简称TSP)是图论中一个著名的组合优化问题,它要求找到访问给定的一组城市并返回起点的最短路径,每个城市只访问一次。在这个问题中,我们通常假设城市之间的距离是...

    程序语言设计原理习题解答

    1.8 Programming Environments 33 Summary • Review Questions • Problem Set 34 Chapter 2 Evolution of the Major Programming Languages 39 2.1 Zuse’s Plankalkül 40 2.2 Minimal Hardware ...

    海蓝风PPT (33).pptx

    模板的第一部分通常用于引入主题,例如“点击输入标题”提示用户在此处填写PPT的主题,而“Just for today I will try to live through this day only and not tackle my whole life problem at once”则可能是一个...

    The Little Book of Semaphores

    33 3.6.2 Reusable barrier problem #1 . . . . . . . . . . . . . . . . 35 3.6.3 Reusable barrier non-solution #2 . . . . . . . . . . . . . . 37 3.6.4 Reusable barrier hint . . . . . . . . . . . . . . ....

    单链表逆置c语言数据结构.cpp

    Problem Description 输入多个整数,以-1作为结束标志,顺序建立一个带头结点的单链表,之后对该单链表的数据进行逆置,并输出逆置后的单链表数据。 Input 输入多个整数,以-1作为结束标志。 Output 输出逆置后...

    ProgrammingLanguage

    You will write 11 SML functions (and tests for them) related to calendar dates....where, for example, 33 represents February 2. (We ignore leap years except in one challenge problem.)

    leetcode338-problem-solving:解决问题

    33:(中) 36:(中) 53:(简单) 59:(中) 66:(简单) 70:(简单) 112:(简单) 113:(中) 121:(简单) 124:(硬) 129:(中) 137:(中) 150:(中) 151:(中) 152:(中) 153:(中) 190...

    POJ3322.rar_poj33_www.3322.se.c

    标题中的"POJ3322.rar_poj33_www.3322.se.c"暗示这是一个关于编程竞赛的问题,POJ(Problem Online Judge)是著名的在线编程竞赛平台,而"3322"是该平台上问题的编号。这个问题可能是从www.3322.se.c这个网站上获取...

    leetcode-problem:leetcode中问题的解决方案

    33.在旋转排序数组中搜索.md 34在排序数组中找到元素的第一个和最后一个位置.md 35-搜索插入位置.md 36-有效的数独.md 38计数与说.md 39-组合-sum.md 40-组合和-ii.md 第43章 第46章 47-置换-ii.md 第48章 ...

Global site tag (gtag.js) - Google Analytics