problem link

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的更多相关文章

  1. AtCoder AISing Programming Contest 2019 Task D. Nearest Card Game

    题目分析在代码注释里. int main() { #if defined LOCAL && !defined DUIPAI ifstream in("main.in" ...

  2. 【AtCoder】ExaWizards 2019

    ExaWizards 2019 C - Snuke the Wizard 发现符文的相对位置不变,直接二分某个位置是否到达最左或最右来计算 #include <bits/stdc++.h> ...

  3. 【AtCoder】diverta 2019 Programming Contest 2

    diverta 2019 Programming Contest 2 A - Ball Distribution 特判一下一个人的,否则是\(N - (K - 1) - 1\) #include &l ...

  4. 【AtCoder】diverta 2019 Programming Contest

    diverta 2019 Programming Contest 因为评测机的缘故--它unrated了.. A - Consecutive Integers #include <bits/st ...

  5. 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 ...

  6. AtCoder Beginner Contest 131 Task F. Must Be Rectangular

    Score: 600 points Approach 固定横坐标 $x$,考虑横坐标为 $x$ 的竖直线上最多可以有几个点. Observations 若最初两条竖直线 $x_1$.$x_2$ 上都有 ...

  7. 【AtCoder】M-SOLUTIONS Programming Contest

    M-SOLUTIONS Programming Contest A - Sum of Interior Angles #include <bits/stdc++.h> #define fi ...

  8. C#并行编程-Task

    菜鸟学习并行编程,参考<C#并行编程高级教程.PDF>,如有错误,欢迎指正. 目录 C#并行编程-相关概念 C#并行编程-Parallel C#并行编程-Task C#并行编程-并发集合 ...

  9. 异步多线程 Task理解

    一.简介 Task是.NET Framework4.0 TPL(任务并行库)提供的新的操作线程池线程的封装类.它提供等待.终止(取消).返回值.完成通知.失败通知.控制执行的先后次序等优化线程操作功能 ...

随机推荐

  1. [Codevs] 矩形面积求并

    http://codevs.cn/problem/3044/ 线段树扫描线矩形面积求并 基本思路就是将每个矩形的长(平行于x轴的边)投影到线段树上 下边+1,上边-1: 然后根据线段树的权值和与相邻两 ...

  2. SSH远程连接排错的过程

    SSH远程连接排错的过程 http://note.youdao.com/noteshare?id=bc81e9036cd2067cb1857ca9f54299a7 补充 ping命令用来测试主机之间网 ...

  3. 【概率论】1-3:组合(Combinatorial Methods)

    title: [概率论]1-3:组合(Combinatorial Methods) categories: Mathematic Probability keywords: Combination 组 ...

  4. 初次Java web项目的建立以及与数据库的连接

    题目要求: 1登录账号:要求由6到12位字母.数字.下划线组成,只有字母可以开头:(1分) 2登录密码:要求显示“• ”或“*”表示输入位数,密码要求八位以上字母.数字组成.(1分) 3性别:要求用单 ...

  5. input上传mp3格式文件,预览并且获取时间

    <input type="file" id="file" name="file" class="upfile" o ...

  6. 你真的会用go语言写单例模式吗?

    最近在学习Golang,想着可以就以前的知识做一些串通,加上了解到go语言也是面向对象编程语言之后.在最近的开发过程中,我碰到一个问题,要用go语言实现单例模式.本着“天下知识,同根同源”(我瞎掰的~ ...

  7. JS函数传递字符串参数(符号转义)

    原文链接:https://blog.csdn.net/Myname_China/article/details/82907965 JS函数传递字符串参数,如果没有转义处理,在接收的时候无法正确的接收字 ...

  8. 从 10.x 到 ArcGIS Pro 的 Python 迁移

    与 ArcGIS Pro 结合使用 Python 的方式与包括 ArcGIS Desktop.ArcGIS Server 以及 ArcGIS Engine 在内的其他 ArcGIS 产品不同. 地理处 ...

  9. Csdn账号如何注销?

    Csdn账号如何注销?   请在ios端app设置内注销 ios端注销在设置页面的底部左下角,andriod在2019.07月底更新,即可支持   文章来源:刘俊涛的博客 欢迎关注,有问题一起学习欢迎 ...

  10. Java动态修改运行环境

    1.pom.xml直接添加一下配置 <profiles> <profile> <id>dev</id> <properties> <a ...