问题描述:
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...
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
在这个“0-1-knapsack-problem-master (33).zip”文件中,很可能包含了一个C语言实现的0-1背包问题解算器。C语言是一种通用的、面向过程的编程语言,因其高效和灵活性而常被用于算法实现。 0-1背包问题的基本描述...
标题中的“0-1-knapsack-problem-master”指的是0-1背包问题,这是一个经典的计算机科学中的优化问题。在0-1背包问题中,我们有一组物品,每种物品都有一个重量和一个价值,目标是在不超过背包最大容量的情况下,...
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)的算法与源代码 电话数字键盘问题 提供移动数字键盘。您只能按向上、向左、向右或向下至当前按钮的按钮。不允许您按最下面一行的角点按钮(即.*和#)。 ...
【压缩包子文件的文件名称列表】"0-1-knapsack-problem-master (33)c.zip" 显示了主代码库的名称,可能包含了实现0-1背包问题算法的源代码文件。虽然这里有一个小错误,两个文件名相同但编号不同(33和34),一般...
### Ant Colony Algorithm for Solving QoS Routing Problem #### 摘要与背景介绍 随着网络技术的不断发展,服务质量(Quality of Service, QoS)成为衡量网络性能的重要指标之一。QoS涉及延迟、抖动、带宽、丢包率...
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 ...
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 ...
每个文件名如"Problem - 1010.mht"代表一个独立的问题,数字部分(如1010)可能是题目编号,而.mht文件格式通常用于存储HTML电子邮件或者单一文件网页,因此这些文件很可能包含了题目的详细描述、输入输出格式、样例...
"新概念英语第二册Lesson33 课件PPT课件.pptx" 本资源是一个英语学习课件,涵盖了多个英语单词和语法知识点。下面是从该资源中提炼出的知识点: 1. Darkness(黑暗):该词可以用来形容环境的黑暗,也可以用来形容...
在小学六年级英语课程中,Lesson 33 到 Lesson 36 及Revision部分,学生需要掌握一系列关键的词汇和表达方式。这些知识点对于提升学生的语言能力至关重要,特别是对于人教四年制的小学英语教育体系。 首先,"learn...
旅行商问题(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的主题,而“Just for today I will try to live through this day only and not tackle my whole life problem at once”则可能是一个...
33 3.6.2 Reusable barrier problem #1 . . . . . . . . . . . . . . . . 35 3.6.3 Reusable barrier non-solution #2 . . . . . . . . . . . . . . 37 3.6.4 Reusable barrier hint . . . . . . . . . . . . . . ....
Problem Description 输入多个整数,以-1作为结束标志,顺序建立一个带头结点的单链表,之后对该单链表的数据进行逆置,并输出逆置后的单链表数据。 Input 输入多个整数,以-1作为结束标志。 Output 输出逆置后...
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.)