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. C模块回调Lua函数的两种方法

    作者:ani_di 版权所有,转载务必保留此链接 http://blog.csdn.net/ani_di C模块回调Lua函数的两种方法 lua和C通过虚拟栈这种交互方式简单而又可靠,缺点就是C做栈平 ...

  2. UVA - 297Quadtrees(四分图)

    Quadtrees Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Statu ...

  3. Swift中类的初始化器与继承

    初始化是类,结构体和枚举类型实例化的准备阶段.这个阶段设置这个实例存储的属性的初始化数值和做一些使用实例之前的准备以及必须要做的其他一些设置工作. 通过定义构造器(initializers)实现这个实 ...

  4. git 使用笔记(三)-分支的使用

    简单介绍 之前说过,每次修改之后,Git 并不是保存这些修改之后的差异变化,实际上就像一个照相机一样,将修改后的文件拍下作为文件快照,记录在一个微型的文件系统中.在 Git 中提交时,会保存一个提交对 ...

  5. 笔记-Node.js中的核心API之HTTP

    最近正在学习Node,在图书馆借了基本关于Node的书,同时在网上查阅资料,颇有收获,但是整体感觉对Node的理解还是停留在一个很模棱两可的状态.比如Node中的模块,平时练习就接触到那么几个,其他的 ...

  6. eclipse中tomcat启动项目 修改java代码不重启服务

    1.双击tomcat 2.选择modules 3.选中项目点击edit 4.去掉勾.去除auto reloading enabled 的选中 ,点击OK,

  7. Problem C: Andy's First Dictionary

    Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...

  8. jbpmAPI-6

    第六章流程. 6.1. What is BPMN 2.0 业务流程模型和符号(BPMN)2.0规范是OMG规范,不仅定义了一个标准的业务流程的图形化表述(如BPMN 1. x),但现在还包括执行语义定 ...

  9. poj 2007 Scrambled Polygon 极角排序

    /** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...

  10. 设置windows密码只存在NTLM-Hash下

    修改注册表 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa 下添加名为"NoLMHash"的DWORD值,并设置为1 ...