ZS and The Birthday Paradox

感觉里面有好多技巧。。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 1e6 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e6 + ;
const double eps = 1e-; LL n, k; LL power(LL a, LL b) {
b %= mod - ;
LL ans = ;
while(b) {
if(b & ) ans = ans * a % mod;
a = a * a % mod; b >>= ;
}
return ans;
} int main() {
scanf("%lld%lld", &n, &k);
if(n < && (1ll << n) < k) {
puts("1 1");
} else {
LL num = ;
for(LL i = k - ; i; i /= ) num += i / ;
LL A = power(, n), B = ;
for(LL i = ; i < k; i++) {
B = B * (A - i) % mod;
if(A == i) break;
}
LL inv = power(power(, num), mod - );
B = B * inv % mod;
A = power(A, k - ) * inv % mod;
printf("%lld %lld\n", (A - B + mod) % mod, A);
}
return ;
} /*
*/

Codeforces 711E ZS and The Birthday Paradox 数学的更多相关文章

  1. Codeforces 711E ZS and The Birthday Paradox

    传送门 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st ...

  2. Codeforces 711E ZS and The Birthday Paradox(乘法逆元)

    [题目链接] http://codeforces.com/problemset/problem/711/E [题目大意] 假设一年有2^n天,问k个小朋友中有两个小朋友生日相同的概率. 假设该概率约分 ...

  3. codeforces 711E. ZS and The Birthday Paradox 概率

    已知一年365天找23个人有2个人在同一天生日的概率 > 50% 给出n,k ,表示现在一年有2^n天,找k个人,有2个人在同一天生日的概率,求出来的概率是a/b形式,化到最简形式,由于a,b可 ...

  4. codeforces 711E E. ZS and The Birthday Paradox(数学+概率)

    题目链接: E. ZS and The Birthday Paradox. time limit per test 2 seconds memory limit per test 256 megaby ...

  5. Codeforces Round #369 (Div. 2) E. ZS and The Birthday Paradox 数学

    E. ZS and The Birthday Paradox 题目连接: http://www.codeforces.com/contest/711/problem/E Description ZS ...

  6. ZS and The Birthday Paradox

    ZS and The Birthday Paradox 题目链接:http://codeforces.com/contest/711/problem/E 数学题(Legendre's formula) ...

  7. CF369E. ZS and The Birthday Paradox

    /* cf369E. ZS and The Birthday Paradox http://codeforces.com/contest/711/problem/E 抽屉原理+快速幂+逆元+勒让德定理 ...

  8. 【Codeforces711E】ZS and The Birthday Paradox [数论]

    ZS and The Birthday Paradox Time Limit: 20 Sec  Memory Limit: 512 MB Description Input Output Sample ...

  9. 【28.57%】【codeforces 711E】ZS and The Birthday Paradox

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. MySQL -- 主从复制的可靠性与可用性

    主库A执行完成一个事务, 写入binlog ,记为 T1 然后传给从库B,从库B 接收该binlog ,记为 T2 从库B执行完成这个事务,记为 T3 同步延时: T3-T1 同一个事务,在 从库执行 ...

  2. NOIP2018退役总结

    NOIP2018退役总结 先说下成绩,应该压线二等. 也没有什么可以抱怨的,真的是心态的问题. 在Day1的时候这么简单的一套卷子,却打了三道暴力,175本来就是省二的水平.回来以后心态就崩了,因为D ...

  3. 【洛谷P2921】Trick or Treat on the Farm

    题目大意:给定一个 N 个节点的内向树森林,求从每个顶点出发能够到达的最多不重复顶点的个数是多少. 题解:内向树森林是由一个或若干个环加若干条链构成.可以先按照类似于拓扑排序的规则进行删链,再对环上的 ...

  4. svn:重命名文件之后,不允许提交

    1.错误代码 org.apache.subversion.javahl.ClientException: Illegal target for the requested operation svn: ...

  5. C/C++ exception类

    #include <iostream> #include <iomanip> #include <string> #include <sstream> ...

  6. 配置httpd2.4与常见的I/O模型说明

    配置httpd2.4与常见的I/O模型说明 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.httpd2.4访问控制 1.基于IP访问控制: 允许所有主机访问:Require a ...

  7. python---django请求-响应的生命周期(FBV和CBV含义)

    Django请求的生命周期是指:当用户在访问该url路径是,在服务器Django后台都发生了什么. 客户端发送Http请求给服务端,Http请求是一堆字符串,其内容是: 访问:http://crm.o ...

  8. Carmichael Numbers (Uva No.10006) -- 快速幂运算_埃氏筛法_打表

    #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> ...

  9. 20155317 王新玮 2016-2017-2 《Java程序设计》第6周学习总结

    20155317 王新玮 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 10.1.1串流设计的概念 Java将输入/输出抽象化为串流,数据有来源及目的地,衔 ...

  10. hadoop - hdfs 基础操作

    hdfs --help # 所有参数 hdfs dfs -help # 运行文件系统命令在Hadoop文件系统 hdfs dfs -ls /logs # 查看 hdfs dfs -ls /user/ ...