Problem 100 Arranged probability (丢番图方程)

Arranged probability

Problem 100

If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2.

The next such arrangement, for which there is exactly 50% chance of taking two blue discs at random, is a box containing eighty-five blue discs and thirty-five red discs.

By finding the first arrangement to contain over 1012 = 1,000,000,000,000 discs in total, determine the number of blue discs that the box would contain.



题解:b*(b-1) / (n*(n-1)) = 1/2 

==>    n^2-2b^2-n+2b = 0

==> (2n-1)^2-2(2p-1^2)= -1

==>上面的是第二型佩尔方程

==>关于第二型佩尔方程的正整数解的通用解法,好像还是一个未解决问题。

==>考虑到(1,1)为这个方程的最小解,记为(x1,y1)则第二型佩尔方程有通解公式:

==>xn=(1/2)((x1+y1sqrt(d))^(2n+1)+(x1-y1sqrt(d))^(2n+1))

==>yn=(1/(2sqrt(d)))((x1+y1sqrt(d))^(2n+1)-(x1-y1sqrt(d))^(2n+1))

==>其中,d=2.
于是,构成线性地推:
x_(n+1) = 3x_n+4y_n
y_(n+1) = 2x_n+3y_n


==>
n0=0,b0=0 and n0=1,b0=1
n(n+1) = P*n(n)+Q*b(n)+K
b(n+1) = R*n(n)+S*b(n)+L
P=3, Q=2, K=-2, R=4, S=3, L=-3


代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n=21,b=15;
	
	while(n<1000000000000L)
	{
		ll tmp_n=4*b+3*n-3;
		ll tmp_b=3*b+2*n-2;
		n=tmp_n;
		b=tmp_b;
	}
	cout<<b<<endl;
	return 0;
}



  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值