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. 【线性代数】6-1:特征值介绍(Introduction to Eigenvalues)

    title: [线性代数]6-1:特征值介绍(Introduction to Eigenvalues) categories: Mathematic Linear Algebra keywords: ...

  2. SpringMVC框架下Web项目的搭建与部署

    这篇文章已被废弃. 现在,Deolin使用Maven构建项目,而不是下载Jar文件,使用Jetty插件调试项目,而不是外部启动Tomcat. SpringMVC比起Servlet/JSP方便了太多 W ...

  3. 2Dot grammar

    http://www.cnblogs.com/mjios/archive/2013/04/08/3006577.html . #import <Foundation/Foundation.h&g ...

  4. 八、linux文件系统上的特殊权限 SUID 、GUID、Sticky

    安全上下文 前提:进程有属主和属组,文件有属主和属组 任何一个可执行程序文件能不能启动为进程:取决发起者对程序文件是否拥有执行权限 启动为进程之后,其进程的属主为发起者:进程的属组为发起者所属的组 进 ...

  5. macOS Mojave 10.14 无法安装brew缺少Command Line Tools for Xcode的解决办法

    问题描述: 首先我的版本是 Xcode 10.1 如果按照以前的方法安装brew 复制 1 /usr/bin/ruby -e "$(curl -fsSL https://raw.github ...

  6. benchmark在postgresql上的安装及使用

     BenchmarkSQL是一款经典的开源数据库测试工具,内嵌了TPCC测试脚本,可以对EnterpriseDB.PostgreSQL.MySQL.Oracle以及SQL Server等数据库直接进行 ...

  7. ExtractIcon function Retrieves a handle to an icon from the specified executable file, DLL, or icon file.

    https://msdn.microsoft.com/zh-cn/vstudio/ms648068(v=vs.90)

  8. springboot整合redis(集群)

    一.加入maven依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...

  9. 给数据库授权,否则程序、navicat无法连接数据库的,每创建一个数据库都要给数据库授权

    给数据库授权,否则程序.navicat无法连接test1数据库的 mysql> grant all privileges on test1.* TO 'root'@'%' identified ...

  10. 初始Hibernate框架

    首先我们需要先创建一个案例 构建一个Student 的实体类 private String name; private Integer age; private Integer id; 在SRC根目录 ...