AtCoder M-SOLUTIONS 2019 Task E. Product of Arithmetic Progression
Official editorial:

code:
int main() {
#if defined LOCAL && !defined DUIPAI
ifstream in("main.in");
cin.rdbuf(in.rdbuf());
// ofstream out("main.out");
// cout.rdbuf(out.rdbuf());
#endif
vector<Mint> fact(md);
fact[0] = 1;
for (int i = 1; i < md; ++i) {
fact[i] = i * fact[i - 1];
}
int Q;
scan(Q);
//1000003是素数
rep (Q) {
int x, d, n;
scan(x, d, n);
// 两种特殊情况:1.d==0,2.数列中出现了0
if (d == 0) {
println(power(Mint(x), n));
continue;
}
if (n >= md || x == 0) {
println(0);
continue;
}
// 在域上是可以做除法的
auto inv_d = inverse(d, md);
if (inv_d < 0) inv_d += md;
int _x = (ll) x * inv_d % md;
if (_x + n - 1 >= md) {
println(0);
} else {
println(fact[_x + n - 1] / fact[_x - 1] * power(Mint(d), n));
}
}
#if defined LOCAL && !defined DUIPAI
cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
AtCoder M-SOLUTIONS 2019 Task E. Product of Arithmetic Progression的更多相关文章
- AtCoder AISing Programming Contest 2019 Task D. Nearest Card Game
题目分析在代码注释里. int main() { #if defined LOCAL && !defined DUIPAI ifstream in("main.in" ...
- 【AtCoder】ExaWizards 2019
ExaWizards 2019 C - Snuke the Wizard 发现符文的相对位置不变,直接二分某个位置是否到达最左或最右来计算 #include <bits/stdc++.h> ...
- 【AtCoder】diverta 2019 Programming Contest 2
diverta 2019 Programming Contest 2 A - Ball Distribution 特判一下一个人的,否则是\(N - (K - 1) - 1\) #include &l ...
- 【AtCoder】diverta 2019 Programming Contest
diverta 2019 Programming Contest 因为评测机的缘故--它unrated了.. A - Consecutive Integers #include <bits/st ...
- Sumitomo Mitsui Trust Bank Programming Contest 2019 Task F. Interval Running
Link. There is a nice approach to this problem that involves some physical insight. In the following ...
- AtCoder Beginner Contest 131 Task F. Must Be Rectangular
Score: 600 points Approach 固定横坐标 $x$,考虑横坐标为 $x$ 的竖直线上最多可以有几个点. Observations 若最初两条竖直线 $x_1$.$x_2$ 上都有 ...
- 【AtCoder】M-SOLUTIONS Programming Contest
M-SOLUTIONS Programming Contest A - Sum of Interior Angles #include <bits/stdc++.h> #define fi ...
- C#并行编程-Task
菜鸟学习并行编程,参考<C#并行编程高级教程.PDF>,如有错误,欢迎指正. 目录 C#并行编程-相关概念 C#并行编程-Parallel C#并行编程-Task C#并行编程-并发集合 ...
- 异步多线程 Task理解
一.简介 Task是.NET Framework4.0 TPL(任务并行库)提供的新的操作线程池线程的封装类.它提供等待.终止(取消).返回值.完成通知.失败通知.控制执行的先后次序等优化线程操作功能 ...
随机推荐
- 「CF716D」Complete The Graph「最短路」
题意 给定一个\(n\)个点\(m\)条边的无向图,有一些边权暂时为\(0\),你需要分配一个\([1, 10^{18}]\)的数.最终使得\(s\)到\(t\)最短路为\(L\),输出一个可行的分配 ...
- scrapy框架之Pipeline管道类
Item Pipeline简介 Item管道的主要责任是负责处理有蜘蛛从网页中抽取的Item,他的主要任务是清洗.验证和存储数据.当页面被蜘蛛解析后,将被发送到Item管道,并经过几个特定的次序处理数 ...
- Hadoop Shell命令字典
转载自:https://www.aboutyun.com//forum.php/?mod=viewthread&tid=6983&extra=page%3D1&page=1&a ...
- Centos 查看CPU个数、核心数等信息
总核数 = 物理CPU个数 X 每颗物理CPU的核数 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数 查看物理CPU个数 cat /proc/cpuinfo| grep & ...
- @EnableTransactionManagement的使用
Spring Boot 使用事务非常简单,首先使用注解 @EnableTransactionManagement 开启事务支持后,然后在访问数据库的Service方法上添加注解 @Transactio ...
- javaEE项目部署方式
1.手动部署 2.自动化部署 “自动化”的具体体现:向版本库提交新的代码后,应运服务器上自动部署
- mysql—并发控制及事务
并发控制 实现的并发访问的控制技术是基于锁: 锁分为表级锁和行级锁,MyISAM存储引擎不支持行级锁:InnoDB支持表级锁和行级锁: 锁的分类有读锁和写锁,读锁也被称为共享锁,加读锁的时候其他的人可 ...
- 使用 pip wheel 实现 Python 依赖包的离线安装
pip python 依赖 安装 有时候, 需要部署 Python 应用的服务器没有网络连接, 这时候, 你就要把整个 Python 应用做成离线安装包. 借助 wheel, 很容易就可以实现. 首先 ...
- flask_security学习笔记
[Flask Security]当不能通过认证的时候制定跳转 Flask Security这个插件能对用户权限进行很好的控制.通过三个model实现:User,存放用户数据Role,存放角色数据U ...
- Hbase shell操作表
启动hbase shell ./bin/hbase shell 1.创建表,查看表 create 'tableName', 'familykey1','familykey2',.... eg. cre ...