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(任务并行库)提供的新的操作线程池线程的封装类.它提供等待.终止(取消).返回值.完成通知.失败通知.控制执行的先后次序等优化线程操作功能 ...
随机推荐
- leetcode解题报告(5):Longest Consecutive Sequence
描述 Given an unsorted array of integers, find the length of the longest consecutive elements sequence ...
- 【luoguSP3267】--莫队,不同数字个数
题意翻译 给出一个长度为n 的数列,a1 a2 ,...an ,有q 个询问,每个询问给出数对(i,j),需要你给出ai ai+1 ,...,aj 这一段中有多少不同的数字 题目 ...
- 前端逼死强迫症系列之Html
概述 HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都来遵守他,这样就可以让浏览器 ...
- ROS机器人开发实践学习笔记2
刚刚开始学习ROS,打算入机器人的坑了,参考教材是<ROS及其人开发实践>胡春旭编著 机械工业出版社 华章科技出品.本来以为可以按照书上的步骤一步步来,但是,too young to si ...
- DataFactory生产身份证号码==
生产身份证号:定义数据类型为CHAR()类型的才能进行数据的组合
- 01背包---P2392 kkksc03考前临时抱佛脚
P2392 kkksc03考前临时抱佛脚 题解 01背包,类似于这道题,相似度99.999999%: 01-背包 P2663 越越的组队 一共有4科,每科的时间独立,然后每一科做一遍 P2663越 ...
- Vue于React特性对比(四)
新开了一个vue的项目,从vue单页面框架搭建到单点登录接入都是自己负责搞的.然后准备将这套东西迁移到react上.然后有了这篇文章. 1,reactjs分环境打包明显要比vue更为麻烦 vue修改的 ...
- LC 955. Delete Columns to Make Sorted II
We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose an ...
- SQL语句中有关单引号、双引号和加号的问题
字符串数据是用单引号包在外面的,而+号只是用来连接这些字符串的. 数据库里的字段是整型的时候不要加单引号,是字符串的时候要加,其它类型根据实际情况来,双引号就是用来拼接字符串的,单引号是sql文的固有 ...
- android设置gps自动开启
1.第一种方法 private void toggleGPS() { Intent gpsIntent = new Intent(); gpsIntent.setClassName("com ...