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. Problem A: 选举 解题报告

    Problem A: 选举 题意 给出一个投票过程.有\(n\)个选民和\(m\)个候选人,每个选民\(i\)有个不重且有序的可投集合\(\{a_i\}\). 对于第一轮投票,选民\(i\)会投给\( ...

  2. alpine编译安装tengine,并使用supervisor启动

    Alpine是一个小型的linux系统,官方docker镜像只有不到5MB,非常适合作为容器镜像. Alpine Linux is a security-oriented, lightweight L ...

  3. Libre 6003 「网络流 24 题」魔术球 (网络流,最大流)

    Libre 6003 「网络流 24 题」魔术球 (网络流,最大流) Description 假设有n根柱子,现要按下述规则在这n根柱子中依次放入编号为 1,2,3,4......的球. (1)每次只 ...

  4. Luogu2661 信息传递(图论)

    Luogu2661 信息传递(图论) Description 有n个同学(编号为1到n)正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为i的同学的信息传递对象是编号为Ti ...

  5. jq禁用html标签

    原文:http://www.jb51.net/article/105154.htm 移除或禁用html元素的点击事件可以通过css实现也可以通过js或jQuery实现. 一.CSS方法 .disabl ...

  6. Java 泛型类型基础

    为什么要使用泛型? 未使用泛型的情况: // 创建列表类 List list = new ArrayList(); // 添加一个类型为 String 的列表元素 list.add("hel ...

  7. JavaScript中的两种全局对象

    这里总结的东西特别适合先学习c/c++, Java这类标准语言再学JS的童鞋们看,因为JS在程序执行之前就会初始化一个全局对象,这个全局对象到底是什么是跟JS程序运行环境有关的. 根据JavaScri ...

  8. Kafka 0.8 sever:源代码High level分析

    本文主要介绍了Kafka High level的代码架构和主要的类. 这张图是0.8版本的架构 Boker 架构 1 network layer Kafka使用NIO自己实现了网络层的代码, 而不是采 ...

  9. Codeforces 666 B. World Tour

    http://codeforces.com/problemset/problem/666/B 题意: 给定一张边权均为1的有向图,求四个不同的点A,B,C,D,使得dis[A][B]+dis[B][C ...

  10. 流媒体技术学习笔记之(六)FFmpeg官方文档先进音频编码(AAC)

    先进音频编码(AAC)的后继格式到MP3,和以MPEG-4部分3(ISO / IEC 14496-3)被定义.它通常用于MP4容器格式; 对于音乐,通常使用.m4a扩展名.第二最常见的用途是在MKV( ...