CF711E.ZS and The Birthday Paradox
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. ZS the Coder finds this very interesting, and decides to test this with the inhabitants of Udayland.
In Udayland, there are 2_n_ days in a year. ZS the Coder wants to interview k people from Udayland, each of them has birthday in one of 2_n_ days (each day with equal probability). He is interested in the probability of at least two of them have the birthday at the same day.
ZS the Coder knows that the answer can be written as an irreducible fraction
. He wants to find the values of A and B (he does not like to deal with floating point numbers). Can you help him?
ZS 这位程序员最近发现了一个有趣的概念,称为“生日悖论”。该悖论指出:在随机选取的 23 个人中,约有 50% 的概率存在其中两人生日相同。ZS 这位程序员对此非常感兴趣,决定在乌代兰(Udayland)的居民中验证这一现象。
在乌代兰,一年共有 2n 天。ZS 这位程序员打算采访乌代兰的 k 位居民,每位居民的生日等概率地落在 2n 天中的某一天。他关心的是:这 k 人中至少有两人生日在同一天的概率。
ZS 这位程序员知道,该概率可表示为一个既约分数 BA(即
)。他希望求出 A 和 B 的值(他不喜欢处理浮点数)。你能帮他吗?
输入格式
The first and only line of the input contains two integers n and k (1 ≤ n ≤ 1018, 2 ≤ k ≤ 1018), meaning that there are 2_n_ days in a year and that ZS the Coder wants to interview exactly k people.
输入仅有一行,包含两个整数 n 和 k(1 ≤ n ≤ 1018,2 ≤ k ≤ 1018),表示一年有 2n 天,且 ZS the Coder 恰好要面试 k 个人。
输出格式
If the probability of at least two k people having the same birthday in 2_n_ days long year equals
(A ≥ 0, B ≥ 1,
), print the A and B in a single line.
Since these numbers may be too large, print them modulo 106 + 3. Note that A and B must be coprime before their remainders modulo 106 + 3 are taken.
若在长度为 2n 天的一年中,至少有两名 k 人拥有相同生日的概率等于
(其中 A ≥ 0,B ≥ 1,且
),请在一行中输出 A 和 B。
由于这些数值可能过大,请将它们对 106+3 取模后输出。注意:在对 106+3 取模之前,A 和 B 必须互质。
输入输出样例
输入#1
3 2
输出#1
1 8
输入#2
1 3
输出#2
1 1
输入#3
4 3
输出#3
23 128
说明/提示
In the first sample case, there are 23 = 8 days in Udayland. The probability that 2 people have the same birthday among 2 people is clearly
, so A = 1, B = 8.
In the second sample case, there are only 21 = 2 days in Udayland, but there are 3 people, so it is guaranteed that two of them have the same birthday. Thus, the probability is 1 and A = B = 1.
在第一个样例中,Udayland 共有 23=8 天。2 个人中存在生日相同的概率显然为
,因此 A=1,B=8。
在第二个样例中,Udayland 仅有 21=2 天,但有 3 个人,因此必然有两人生日相同。于是该概率为 1,且 A=B=1。
输入解题思路,AI测评打分。不知道怎么写?