small test on 5.30 night T1

数学题使劲推就对了。
让我们设 g(x) = ∑ C(i,x) * b^i ,然后后面验算了一张纸QWQ,懒得再打一遍了,回家我就把这张演算纸补上QWQ,先上代码。

#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500005,ha=998244353;
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}
inline int ksm(int x,int y){
int an=1;
for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
return an;
} int b,k,ans,inv[maxn],mul,ni;
ll n; int main(){
freopen("diyiti.in","r",stdin);
freopen("diyiti.out","w",stdout); scanf("%lld%d%d",&n,&b,&k),n++; inv[1]=1;
for(int i=2;i<=k;i++) inv[i]=ha-inv[ha%i]*(ll)(ha/i)%ha; mul=ksm(b,n%(ha-1)),ni=ksm(b-1,ha-2);
ans=add(add(mul,ha-1)*(ll)ni%ha,ha-1); n%=ha;
for(int i=1,now=mul;i<=k;i++){
now=now*n%ha*(ll)inv[i]%ha,n=add(n,ha-1);
ans=add(now,add(ha-b*(ll)ans%ha,ha-(i==1?b:0)));
ans=ans*(ll)ni%ha;
} printf("%d\n",ans);
return 0;
}
small test on 5.30 night T1的更多相关文章
- c# ContinueWith 用法
通过任务,可以指定在任务完成之后,应开始运行之后另一个特定任务.例如,一个使用前一个任务的结果的新任务,如果前一个任务失败了,这个任务就应执行一些清理工作.任务处理程序都不带参数或者带一个对象参数,而 ...
- Bootstrap_CSS全局样式
一.HTML5 文档类型 Bootstrap 使用到的某些 HTML 元素和 CSS 属性需要将页面设置为 HTML5 文档类型.在你项目中的每个页面都要参照下面的格式进行设置. <!DOCTY ...
- 利用no_merge优化
SQL> select a.unit3_code 机构编码, 2 a.unit3_name 机构名称, 3 a.dept1_code 部门编码, 4 a.dept1_name 部门名称, 5 a ...
- 9.20 noip模拟试题
Problem 1 双色球(ball.cpp/c/pas) [题目描述] 机房来了新一届的学弟学妹,邪恶的chenzeyu97发现一位学弟与他同名,于是他当起了善良的学长233 “来来来,学弟,我 ...
- NOIP2017+停课总结
注意 此文章禁止一切含虚伪内容的评论,违者删除评论 其删除解释权归博主所有 Part1 论yyb NOIP 如何炸裂 前言 离NOIP已有三个星期,忘却的救主快要降临了吧,我正有写一篇总结的必要了.. ...
- python之单例模式、栈、队列和有序字典
一.单例模式 import time import threading class Singleton(object): lock = threading.RLock() # 定义一把锁 __inst ...
- python之collection模块
collections模块 一.总览 在内置数据类型(int.float.complex.dict.list.set.tuple)的基础上, collections模块还提供了几个额外的数据类型:Co ...
- 模组 前后端分离CURD 组件
js (function () { // {# -------------------------------------------------------------------------- # ...
- python基础之 time,datetime,collections
1.time模块 python中的time和datetime模块是时间方面的模块 time模块中时间表现的格式主要有三种: 1.timestamp:时间戳,时间戳表示的是从1970年1月1日00:00 ...
随机推荐
- Bash script: report largest InnoDB files
The following script will report the largest InnoDB tables under the data directory: schema, table & ...
- POJ 2398 Toy Storage 二分+叉积
Description Mom and dad have a problem: their child, Reza, never puts his toys away when he is finis ...
- 使用babel把es6代码转成es5代码
第一步:创建一个web项目 使用命令:npm init 这个命令的目的是生成package.json. 执行第二步中的命令后生成的package.json的文件的内容是: { "name&q ...
- zigbee ---- endpoint理解
很多资料将其翻译为“端点”,我们不如也这么叫. 在windows上使用不同的软件进行通信,数据包到达不同的应用的方法就是通过寻找IP地址和端口号来确定某一个应用的,也就是我们所说的五元组(源IP,目的 ...
- MySQL 8.0.11(zip)安装及配置
(1)下载MySQL8.0.11: (2)解压zip文件: 我解压到了D:/MySQL/mysql-8.0.11-winx64 (3)配置环境变量: 右键此电脑->属性 高级系统设置 环境变 ...
- 关于applePay详细讲解
https://www.cnblogs.com/diweinan/p/6225501.html
- hadoop之shuffle详解
Shuffle描述着数据从map task输出到reduce task输入的这段过程. 如map 端的细节图,Shuffle在reduce端的过程也能用图上标明的三点来概括.当前reduce copy ...
- 【spoj8222-Substrings】sam求子串出现次数
http://acm.hust.edu.cn/vjudge/problem/28005 题意:给一个字符串S,令F(x)表示S的所有长度为x的子串中,出现次数的最大值.求F(1)..F(Length( ...
- Backbone Collection 源码简谈
一切由一个例子引发: var Man=Backbone.Model.extend({ initilize:function(){ this.bind('change:name',function(){ ...
- mybatis generator 生成带中文注释的model类
将org.mybatis.generator.interal.DefaultCommentGenerator类的addFieldComment方法重写,代码如下: public void addFie ...