越狱 BZOJ
来源:互联网 发布:js跨域请求的几种方式 编辑:程序博客网 时间:2024/06/05 21:49
题目传送门
思路:这个题正着想不容易想,但是我们可以去想怎么才能让越狱不发生,也就是任何两个相邻的人的信仰都不相同,然后再用所有的情况减去这个情况就好了。
#include <algorithm>#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <list>#include <map>#include <queue>#include <set>#include <stack>#include <string>#include <vector>#define MAXN 1000010#define MAXE 5#define INF 0x7ffffff#define MOD 100003#define LL long long#define ULL unsigned long long#define pi 3.14159using namespace std;LL MI(LL a, LL b) { LL ans = 1; while (b) { if (b & 1) { ans = ans * a % MOD; } b >>= 1; a = a * a % MOD; } return ans % MOD;}int main() { std::ios::sync_with_stdio(false); LL m, n; cin >> m >> n; LL sum1 = MI(m, n); LL sum2 = m; sum2 %= MOD; sum2 = sum2 * MI(m - 1, n - 1) % MOD; cout << (sum1 - sum2 + MOD) % MOD << endl; return 0;}
阅读全文
0 0
- 越狱 BZOJ
- bzoj 1008: [HNOI2008]越狱
- [BZOJ 1008][HNOI2008]越狱
- [BZOJ 1008] [HNOI2008]越狱
- BZOJ 1008 越狱
- bzoj 1008: [HNOI2008]越狱
- 【BZOJ】1008 越狱
- bzoj 1008 [HNOI2008]越狱
- BZOJ 1008 越狱
- BZOJ 1008: [HNOI2008]越狱
- BZOJ 1008 [HNOI2008]越狱
- 【bzoj 1008】 越狱
- BZOJ[1008]越狱
- BZOJ 1008 [HNOI2008] 越狱
- BZOJ 1008 [HNOI2008] 越狱
- BZOJ 1008 越狱 【数论】
- 【BZOJ 1008】[HNOI2008]越狱
- 【BZOJ】1008: [HNOI2008]越狱
- 10.6日常总结
- 1.2.2JVM JRE JDK说明
- Educational Codeforces Round 30
- 主成分分析简单例子
- Java多线程
- 越狱 BZOJ
- 输入一个字符串,大写转换成小写,小写不变。
- Java Activiti(10)--与spring整合配置文件activiti-context.xml
- 线性表综合实验之双链表的实现
- hdu 6161 Big binary tree
- 多路复用和多路分用
- POJ 2430 Lazy Cows 笔记
- python 第三天
- 微信小程序实战小小应用——豆瓣电影