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. HDU 5823 color II(FWT)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5823 [题目大意] 定义一张无向图的价值:给每个节点染色使得每条边连接的两个节点颜色不相同的最少颜 ...

  2. 三分钟教你学Git(十六) - 统计

    有时候想统计仓库的情况,比方代码量.贡献者之类的. 1 统计某人的commit数量 git log --author="$(git config --get user.name)" ...

  3. telnet登陆路由器。。。

    登陆路由有两种方式.一种是console,还有一种是使用telnet,由于我电脑是win7,不支持console.也懒得装软件,就使用telnent为例. 一.开启telnetclient 对于XP. ...

  4. HDU 2149-Public Sale(巴什博奕)

    Public Sale Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  5. 2.一步一步学c#(二):核心c#

    简单的控制台应用程序. 代码(它有把某条消息写到屏幕上的一个类组成) 编译并运行程序得到结果: 在上面的代码示例中,前几行代码与名称空间有关,名称空间是把相关类组合在一起的方式.namespace关键 ...

  6. jQuery 插件 flexslider 初步使用

    发现了个不错的 jQuery 幻灯片插件 flexslider,有 接近 3000 Star,应该说是很靠谱的,下面是简单使用教程. 引入代码 所有代码都可以在 flexlslider 的 Githu ...

  7. Java中布尔类型操作符&=,|=与^=的使用

    今天在对同事的代码进行code review的时候,见到一个比较好玩的写法.“flag &= false:”,乍一看,还感觉他写错了,但是程序可以正常运行,赶紧去百度,看一下这个写法到底是怎么 ...

  8. iOS 10中如何搭建一个语音转文字框架

    在2016WWDC大会上,Apple公司介绍了一个很好的语音识别的API,那就是Speech framework.事实上,这个Speech Kit就是Siri用来做语音识别的框架.如今已经有一些可用的 ...

  9. Construct Binary Tree From Inorder and Preorder/Postorder Traversal

    map<int, int> mapIndex; void mapToIndex(int inorder[], int n) { ; i < n; i++) { mapIndex.in ...

  10. POJ 3974 Palindrome(最长回文子串)

    题目链接:http://poj.org/problem?id=3974 题意:求一给定字符串最长回文子串的长度 思路:直接套模板manacher算法 code: #include <cstdio ...