鱼C论坛

 找回密码
 立即注册
查看: 2289|回复: 1

题目243:分数的弹性

[复制链接]
发表于 2017-1-6 22:16:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 永恒的蓝色梦想 于 2020-8-30 19:13 编辑
Resilience

A positive fraction whose numerator is less than its denominator is called a proper fraction.
For any denominator, d, there will be d-1 proper fractions; for example, with d = 12:
1/12 , 2/12 , 3/12 , 4/12 , 5/12 , 6/12 , 7/12 , 8/12 , 9/12 , 10/12 , 11/12 .

We shall call a fraction that cannot be cancelled down a resilient fraction.
Furthermore we shall define the resilience of a denominator, R(d), to be the ratio of its proper fractions that are resilient; for example, R(12) = 4/11 .
In fact, d = 12 is the smallest denominator having a resilience R(d) < 4/10 .

Find the smallest denominator d, having a resilience R(d) < 15499/94744 .

题目:

分子小于分母的正分数叫做真分数。

对于任何分母 d,存在 d-1 个真分数;例如 d = 12 时有:
1/12 , 2/12 , 3/12 , 4/12 , 5/12 , 6/12 , 7/12 , 8/12 , 9/12 , 10/12 , 11/12

我们称一个不能化简的分数为弹性分数。
进一步我们定义分母的弹性 R(d),即弹性分数与其真分数的比;例如,R(12) = 4/11
实际上, d = 12 为满足弹性R(d) < 4/10 的最小分母。

求最小的分母 d,使得弹性 R(d) < 15499/94744


想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-8-28 10:59:54 | 显示全部楼层
本帖最后由 jerryxjr1220 于 2017-8-28 14:35 编辑

这题是“欧拉计划”的第243题,做完这题解锁了一个新的成就
Untitled.png
程序的话,先贴个Bruce Force的方法,大概要500多秒才能出结果。
import numpy as np 
from numba import jit
@jit
def euler243(target, limit):
        primes = np.ones(limit, dtype='int8')
        for i in range(2, int(limit**0.5+1)):
                primes[i*i::i] = 0
        plist=np.nonzero(primes)[0][2:].tolist()
        PHI = np.zeros(limit+1, dtype='int32')
        PHI[:2:1] = -1
        for p in plist:
                PHI[p] = p - 1
        for p in plist:
                for k in range(p*p, limit+1, p):
                        PHI[k] = PHI[k//p]*(p-1)
                for j in range(p*p, limit+1, p*p):
                        PHI[j] = PHI[j//p]*p
        x = 2
        while (PHI[x]/(x-1)) >= target:
                x += 1
        else:
                print(x)
                return
euler243(15499/94744, 1000000000)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-2 21:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表