The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that49/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.

题目大意:

分数 49/98 是一个奇怪的分数:当一个菜鸟数学家试图对其进行简化时,他可能会错误地可以认为通过将分子和分母上的9同时去除得到 49/98 = 4/8。但他得到的结果却是正确的。

我们将30/50 = 3/5这样的分数作为普通个例。

一共有四个这样的非普通分数,其值小于1,并且包括分子和分母都包括2位数。 如果将这四个分数的乘积约分到最简式,分母是多少?

//(Problem 33)Digit canceling fractions
// Completed on Thu, 25 Jul 2013, 17:47
// Language: C
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/
#include<stdio.h>
void swap(int *a, int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
} int gcd(int a, int b)
{
int r;
if (a < b)
swap(&a,&b);
if (!b)
return a;
while ((r = a % b) != ) {
a = b;
b = r;
}
return b;
} void find()
{
int i;
int M,N;
M=N=;
for(i=; i<; i++)
{
for(int j=i+; j<; j++)
{
int t=gcd(i,j);
if(t== || i/t> || j/t> || i%!=j/)
continue;
else
{
int a=i/,b=j%;
if(a/gcd(a,b)==i/t && b/gcd(a,b)==j/t)
{
M*=i/t;
N*=j/t;
}
}
}
}
printf("%d\n",N/gcd(M,N));
} int main()
{
find();
return ;
}
Answer:
100

(Problem 33)Digit canceling fractions的更多相关文章

  1. (Problem 74)Digit factorial chains

    The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...

  2. (Problem 34)Digit factorials

    145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...

  3. (Problem 73)Counting fractions in a range

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  4. (Problem 72)Counting fractions

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  5. (Problem 16)Power digit sum

    215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...

  6. (Problem 46)Goldbach's other conjecture

    It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...

  7. (Problem 29)Distinct powers

    Consider all integer combinations ofabfor 2a5 and 2b5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, ...

  8. (Problem 57)Square root convergents

    It is possible to show that the square root of two can be expressed as an infinite continued fractio ...

  9. (Problem 42)Coded triangle numbers

    The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...

随机推荐

  1. Java知识点复习

    总结下java的知识点 final 关键字-方法:不能被子类重写(override)-变量:不能被修改-类:不可以被继承,派生子类 finally 关键字与try/catch语句配合使用,即使有异常抛 ...

  2. mysql的函数

  3. Html 语法学习笔记二

    1.图像标签(<img>)和源属性(Src) 在 HTML 中.图像由 <img> 标签定义.        <img> 是空标签,意思是说,它仅仅包括属性,而且没 ...

  4. sql语句开发使用---update

    单表的更新大家都用过了,现在说下实际开发过程中,需要多表的查询更新状态,或者跨数据库的更新状态. 东西需要学习了才会懂得,所以站在巨人的肩膀看的更远. sql 语法; UPDATE 表名称 SET 列 ...

  5. js动画学习(五)

    九.多属性同时运动 前面的例子都是每个属性单独运动,如果想要多属性同时运动怎么办?比如,我想要一个div的onmouseover事件中宽和高同时变化.下面这个函数是单独变宽: window.onloa ...

  6. iframe的一些简单记录

    //获取当前所在IFrame的id var frameId = window.frameElement && window.frameElement.id || ''; //Jquer ...

  7. CodeForces 452C Magic Trick (排列组合)

    #include <iostream> #include <cstdio> #include<cmath> #include<algorithm> us ...

  8. 正则语法笔记-regular expression note

    参考文档:python正则表达式 正则表达式定义:正则是一门高度专业编程语言,内嵌在其他语言(python re模块)中使用.正则表达式包含元字符(metacharacter)列表,列表如下: . ^ ...

  9. Linux中fork()函数详解(转载)

    [原创地址]http://blog.csdn.net/jason314/article/details/5640969 [转载地址]http://www.cnblogs.com/bastard/arc ...

  10. Git merge local repository

    I've met this problem for so many times and let me write a blog for solving this problem. First, you ...