_bzoj1008 [HNOI2008]越狱【计数】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1008
水题。。。
#include <cstdio> const int mod = 100003; long long m, n; inline int poww(long long di, long long mi) {
int i;
for (i = 63; mi >> i & 1 ^ 1; --i);
long long rt = di;
for (--i; ~i; --i) {
rt = rt * rt % mod;
if (mi >> i & 1) {
rt = rt * di % mod;
}
}
return (int)rt;
} int main(void) {
scanf("%lld%lld", &m, &n);
printf("%d\n", (poww(m, n) - (m * poww(m - 1, n - 1) % mod) + mod) % mod);
return 0;
}
_bzoj1008 [HNOI2008]越狱【计数】的更多相关文章
- bzoj1008 [HNOI2008]越狱
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 5099 Solved: 2207 Description 监狱有 ...
- 【bzoj1008】[HNOI2008]越狱
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 7692 Solved: 3296[Submit][Status] ...
- BZOJ 1008: [HNOI2008]越狱 快速幂
1008: [HNOI2008]越狱 Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生 ...
- BZOJ 1008 [HNOI2008]越狱
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 5166 Solved: 2242[Submit][Status] ...
- BZOJ1008: [HNOI2008]越狱-快速幂+取模
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 8689 Solved: 3748 Description 监狱有 ...
- BZOJ 1008 [HNOI2008]越狱 (简单排列组合 + 快速幂)
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 10503 Solved: 4558[Submit][Status ...
- 洛谷 P3197 [HNOI2008]越狱 解题报告
P3197 [HNOI2008]越狱 题目描述 监狱有连续编号为\(1-N\)的\(N\)个房间,每个房间关押一个犯人,有\(M\)种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可 ...
- [HNOI2008]越狱 题解(容斥原理+快速幂)
[HNOI2008]越狱 Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多 ...
- BZOJ 1008 [HNOI2008]越狱 排列组合
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 4788 Solved: 2060[Submit][Status] ...
随机推荐
- Apache 处理svg工具包Apache(tm) Batik SVG Toolkit
Apache™ Batik SVG Toolkit¶ Overview¶ Batik is a Java-based toolkit for applications or applets that ...
- 2003-07-16T01:24:32Z这是什么时间格式
这是标准的XML Schema的"日期型数据格式”. T是代表后面跟着“时间”.Z代表0时区,或者叫UTC统一时间. 世界的每个地区都有自己的本地时间,在Internet及无线电通信时,时间 ...
- Prime Distance(二次筛素数)
Description The branch of mathematics called number theory is about properties of numbers. One of th ...
- leetCode 67.Add Binary (二进制加法) 解题思路和方法
Given two binary strings, return their sum (also a binary string). For example, a = "11" b ...
- 用Visual Studio高版本号打开低版本号的project,转换时出现错误:fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
解决方法是: 在电脑里面搜索发现 C:\Program Files\Microsoft Visual Studio 10.0\VC\bin C:\Windows\winsxs\x86_netf ...
- CSS 相对|绝对(relative/absolute)定位系列(一)
一.有话要说 以前写内容基本上都是:眼睛一亮——哟呵,这个不错,写!然后去古人所说的茅房里蹲会儿,就有写作的思路了.但是,构思相对/绝对(relative/absolute)定位系列却有好些时日,考虑 ...
- 【转载】How browsers work--Behind the scenes of modern web browsers (前端必读)
浏览器可以被认为是使用最广泛的软件,本文将介绍浏览器的工 作原理,我们将看到,从你在地址栏输入google.com到你看到google主页过程中都发生了什么. 将讨论的浏览器 今天,有五种主流浏览器- ...
- 【剑指Offer面试题】 九度OJ1517:链表中倒数第k个结点
鲁棒性是指程序可以推断输入是否符合规范要求,并对不和要求的输入予以 合理的处理. 题目链接地址: http://ac.jobdu.com/problem.php?pid=1517 题目1517:链表中 ...
- Python的调用程序
任务 调用系统命令ping 判断局域网内有哪些主机存活 假设你用c语言写了一个算法,需要对该算法进行测试.测试的数据集几百个.这时可以使用过GCC生成test.exe,再使用python批量调用该ex ...
- c++代码赏析之类对象传參
#include <iostream> using namespace std; class A { private: int x; public: A():x(0) { x = 0; c ...