Codeforces 711E 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 数学的更多相关文章
- Codeforces 711E ZS and The Birthday Paradox
传送门 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st ...
- Codeforces 711E ZS and The Birthday Paradox(乘法逆元)
[题目链接] http://codeforces.com/problemset/problem/711/E [题目大意] 假设一年有2^n天,问k个小朋友中有两个小朋友生日相同的概率. 假设该概率约分 ...
- codeforces 711E. ZS and The Birthday Paradox 概率
已知一年365天找23个人有2个人在同一天生日的概率 > 50% 给出n,k ,表示现在一年有2^n天,找k个人,有2个人在同一天生日的概率,求出来的概率是a/b形式,化到最简形式,由于a,b可 ...
- 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 ...
- 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 ...
- ZS and The Birthday Paradox
ZS and The Birthday Paradox 题目链接:http://codeforces.com/contest/711/problem/E 数学题(Legendre's formula) ...
- CF369E. ZS and The Birthday Paradox
/* cf369E. ZS and The Birthday Paradox http://codeforces.com/contest/711/problem/E 抽屉原理+快速幂+逆元+勒让德定理 ...
- 【Codeforces711E】ZS and The Birthday Paradox [数论]
ZS and The Birthday Paradox Time Limit: 20 Sec Memory Limit: 512 MB Description Input Output Sample ...
- 【28.57%】【codeforces 711E】ZS and The Birthday Paradox
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- NOI2018旅游记
这居然是我第一次参加非NOIP的NOI系列赛事,有点小期待啊 前几天的UNR我暴露出了许多问题,而且翻了好多分,不过令人震惊的是假设Day1不停电(导致已经写好的T3没交上去)我居然有rk10,虽然并 ...
- 背包问题的优化(洛谷1776 宝物筛选_NOI导刊)
背包型dp,但是没有看清数据范围差点认为是水题了,(然后诡异的拿了20分)标解是:2进制优化,比较简单把每一类物品看做若干个相互独立的物品,放在一个另外的数组里,然后全局跑一边01就可以.主要思想是: ...
- CF1096D Easy Problem(DP)
貌似最近刷了好多的CF题…… 题目链接:CF原网 洛谷 题目大意:有一个长度为 $n$ 的字符串 $s$,删除第 $i$ 个字符需要代价 $a_i$.问使得 $s$ 不含有子序列(不是子串)" ...
- spring data jpa createNativeQuery 错误 Unknown entity
springdatajpa本地查询的时候,报错:org.hibernate.MappingException: Unknown entity: com.hzxc.guesssong.model.Que ...
- LOJ#2983. 「WC2019」数树
传送门 抄题解 \(Task0\),随便做一下,设 \(cnt\) 为相同的边的个数,输出 \(y^{n-cnt}\) \(Task1\),给定其中一棵树 设初始答案为 \(y^n\),首先可以发现, ...
- virtualenv和virtualenvwrapper介绍和使用
virtualen介绍 virtualenv优点: 工具可以创建隔离的Python环境 . 环境升级不影响其他应用,也不会影响全局的python环境 它可以防止系统中出现包管理混乱和版本的冲突 vir ...
- Hadoop基础-MapReduce的Partitioner用法案例
Hadoop基础-MapReduce的Partitioner用法案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Partitioner关键代码剖析 1>.返回的分区号 ...
- 【转载】SQL注入原理讲解
这几篇文章讲的都很不错,我看了大概清除了sql注入是怎么一回事,打算细细研究一下这个知识,另写一篇博客: 原文地址:http://www.cnblogs.com/rush/archive/2011/1 ...
- css左右等高问题
先看看预览效果:http://lgdy.whut.edu.cn/index.php?c=home&a=detail&id=3394 再来谈谈css左右等高的应用场景:在内容管理系统(c ...
- python技巧 is 和 ==
is 判断变量是否指向同一个对象 == 判断变量引用的对象是否相等 In [2]: a=[1,2] In [3]: b=a In [4]: a == b Out[4]: True In [5]: a ...