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 ...
随机推荐
- bzoj1052
Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄 膜把这些小树遮盖起来,经过一番长久的思考,他决定用3个L*L的正方形塑料薄膜将 ...
- 【BZOJ2067】SZN(二分,动态规划,贪心)
[BZOJ2067]SZN(二分,动态规划,贪心) 题面 权限题额 Description String-Toys joint-stock 公司需要你帮他们解决一个问题. 他们想制造一个没有环的连通图 ...
- 学习7__STM32--SPI外设之双机通信---
<target> # 整透stm32之spi双机通信(包括双机同为stm32,stm32& others) <概念> # 双机通信(全双工) 在主机的MOSI管脚输出1 ...
- Linux上查看文件大小的用法(转载)
具体用法可以参考:https://blog.csdn.net/linfanhehe/article/details/78560887 当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常 ...
- Linux上常用的基本命令
复制:copy [keysystem@localhost happydzy]$ cp file1 file2 [keysystem@localhost happydzy]$ ll total -rw- ...
- Python3:if __name__ == '__main__' 详解
一般在风格比较好的代码中会有一行if __name__ == '__main__' :代码,这里说明一下这句代码的用处,先上两个代码test1.py和test2.py: # test1.py prin ...
- python教程2:list和tuple
list和tuple都是数组,区别在于list可以随意增删改查,而tuple在赋值了之后只能查看了,所以tuple是比较安全的相对于list来说 list 定义一个list数组,名字就叫list,可以 ...
- Numpy - Pandas - Matplot 功能与函数名 速查
用Python做数据分析,涉及到的函数实在是太多了,容易忘记,去网上查中文基本上差不到,英文有时候描述不清楚问题. 这里搞个针对个人习惯的函数汇总速查手册,下次需要用一个什么功能,就在这里面查到对应的 ...
- Codeforces Round #519 题解
A. Elections 题意概述 给出 \(a_1, \ldots, a_n\),求最小的 \(k (k \ge \max a_i)\), 使得 \(\sum_{i=1}^n a_i < \s ...
- 2018年9月28日CCPC秦皇岛站参赛总结
day1: 被中间结果超出int范围给叉了,立刻意识到了自己的弱小以及校赛出题的时候是怎么叉别人的 day2: 签到签了40分钟,谨慎一些还是很好的,机子重启耽误了一些时间 一道暴力+LCS的简单题被 ...