问题描述:
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...
0-1-knapsack-problem-master (33).zip
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
原神抽卡模拟器
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 ...
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 ...
3 words in a Gimpy image 33% of the time. The problem of identifying words in such severe clutter provides valuable insight into the more general problem of object recognition in scenes. The methods ...
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 ...
2.7.1 Formulation 1 for Column Design 33 2.7.2 Formulation 2 for Column Design 34 2.8 Minimum Cost Cylindrical Tank Design 35 2.9 Design of Coil Springs 36 2.10 Minimum Weight Design of a Symmetric ...
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.)
33:(中) 36:(中) 53:(简单) 59:(中) 66:(简单) 70:(简单) 112:(简单) 113:(中) 121:(简单) 124:(硬) 129:(中) 137:(中) 150:(中) 151:(中) 152:(中) 153:(中) 190...
33.在旋转排序数组中搜索.md 34在排序数组中找到元素的第一个和最后一个位置.md 35-搜索插入位置.md 36-有效的数独.md 38计数与说.md 39-组合-sum.md 40-组合和-ii.md 第43章 第46章 47-置换-ii.md 第48章 ...
33 9 153 10 80 11 128 12 102 13 199 14 200 15 11 16 209 17 73 18 78 19 46 20 22 21 56 22 238 23 15 24 560 25 253 26 289 27 17 参考 描述 代码 二维数组 DFS 遍历 二维数组 BFS 遍历 树遍历 树 DFS 遍历 反向...
The Shellcoder's Handbook 2nd Edition About the Authors vii Acknowledgments xi ...The Address Problem 27 The NOP Method 33 Defeating a Non-Executable Stack 35 Return to libc 35 Conclusion 39
Chapter 33. Hermes: A Distributed-Messaging Tool for NLP Chapter 34. Deep Learning for Classification of Dental Plaque Images Chapter 35. Multiscale Integration for Pattern Recognition in Neuroimaging...
Defining a Problem. . . . . . . . . . 1-10 Using the Neural Network Fitting Tool . . 1-12 Using Command-Line Functions . . . . . . . 1-23 Classify Patterns with a Neural Network . . 1-33 Defining a ...