Generation I
Generation I
Now Oak is going to do N operations. In the i-th operation, he will insert an integer x between 1 and M to every set indexed between i and N.
Oak wonders how many different results he can make after the N operations. Two results are different if and only if there exists a set in one result different from the set with the same index in another result.
Please help Oak calculate the answer. As the answer can be extremely large, output it modulo 998244353.
输入描述:
The input starts with one line containing exactly one integer T which is the number of test cases. (1 ≤ T ≤ 20) Each test case contains one line with two integers N and M indicating the number of sets and the range of integers.
(1 ≤ N ≤ 1018, 1 ≤ M ≤ 1018, )
输出描述:
For each test case, output "Case #x: y" in one line (without quotes), where x is the test case number (starting from 1) and y is the number of different results
modulo 998244353.
输入
2
2 2
3 4
输出
Case #1: 4
Case #2: 52
#include <iostream>
#define N 1000005
using namespace std;
const long long mod=;
long long ny[N+];
long long f(long long a,long long b)
{
long long ans=;
while(b>)
{
if(b%==)ans=(ans*a)%mod; b/=;
a=(a*a)%mod;
}
return ans;
} int main()
{
int t,tot=;
scanf("%d",&t);
for(int i=;i<=N;i++)ny[i]=f(i,mod-); while(t--)
{
long long n,m,ans,upper,last;
scanf("%lld %lld",&n,&m); upper=min(n,m);
ans=last=m%mod; for(int i=;i<=upper;i++)
{
last*=(m+-i)%mod;
last%=mod;
last*=ny[i-];
last%=mod;
last*=(n+-i)%mod;
last%=mod;
ans+=last;
ans%=mod;
} printf("Case #%d: %lld\n",++tot,ans);
}
return ;
}
Generation I的更多相关文章
- 论文阅读(Zhuoyao Zhong——【aixiv2016】DeepText A Unified Framework for Text Proposal Generation and Text Detection in Natural Images)
Zhuoyao Zhong--[aixiv2016]DeepText A Unified Framework for Text Proposal Generation and Text Detecti ...
- Task set generation
Task set generation for uni- and multiprocessors: “Unifying Fixed- and Dynamic-Priority Scheduling b ...
- 使用-MM生成include指令和依赖生成(make include directive and dependency generation with -MM)
I want a build rule to be triggered by an include directive if the target of the include is out of d ...
- PHPNG (next generation)
PHPNG (next generation) This page gives short information about development state of a new PHP branc ...
- test generation和MBIST
The problem of test generation Random test generation Deterministic algorithm for test generation fo ...
- 关于conversation generation的论文笔记
对话模型此前的研究大致有三个方向:基于规则.基于信息检索.基于机器翻译.基于规则的对话系统,顾名思义,依赖于人们周密设计的规则,对话内容限制在特定领域下,实际应用如智能客服,智能场馆预定系统.基于信息 ...
- 1094. The Largest Generation (25)
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level bel ...
- Case Study: Random Number Generation(翻译教材)
很荣幸,经过三天的努力.终于把自己翻译的教材做完了,现在把它贴出来,希望能指出其中的不足. Case Study: Random Number Generation Fig. 6.7 C++ 标 ...
- Index Generation
Index Generation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 230 Accepted: 89 Des ...
- PowerDesigner15(16)在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
1.用PowerDesigner15建模,在Database—>Generate Database (或者用Ctrl+G快捷键)来生产sql语句,却提示“Generation aborted d ...
随机推荐
- COGS 615. 韩国明星
[问题描述] 在LazyCat同学的影响下,Roby同学开始听韩国的音乐,并且越来越喜欢H.o.T,尤其喜欢安七炫和Tony,可是,爱学习爱思考的Roby同学想,如果以后喜欢的韩星越来越多怎么办呢?R ...
- COGS 264. 数列操作
时间限制:1 s 内存限制:160 MB [问题描述] 假设有一列数 {Ai }(1 ≤ i ≤ n) ,支持如下两种操作: (1)将 A k 的值加 D .( k, D 是输入的数) (2) 输 ...
- maven打包错误:java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.118 sec <<< FAILURE! - in ...
- 虚拟机ubuntu16.0 安装 mysql 主机配置访问
在bantu服务器中安装如下命令 sudo apt-get install mysql-server sudo apt-get install mysql-client安装成功之后 进入配置文件 ...
- 国家气象局提供的天气预报接口(完整Json接口)
国家气象局提供的天气预报接口主要有三个,分别是:http://www.weather.com.cn/data/sk/101010100.htmlhttp://www.weather.com.cn/da ...
- 数据库_4_SQL介绍
SQL SQL:Structured Query Language,结构化查询语言(数据已查询为主:99%是在进行查询操作) what型语言,而非how型的语言. SQL分为三个部分: DDL: ...
- Java Miniui实现批量上传文件demo 201906221520
可能需要的jar包: 需要miniui(类似easyui). Test2019062201.jsp <%@ page language="java" contentType= ...
- Base64编码密钥时关于换行的几个问题。
在windows下一个javaweb应用,需要用http传递公钥pk.一般是String pk = BASE64ENCODER.encode(pkBytes);base64编码时,每76个字母就要换行 ...
- KVM 重命名虚机
KVM 重命名虚机 1. 查看虚机列表 [root@bjape01-kvm1 ~]# virsh list --all Id 名称 状态 --- ...
- Clover启动mbr的win7/win8
对以传统bios安装在mbr分区的win7/WIN8也可以使用EFI引导直接进入win.首先进win提取EFI引导文件,以管理员员身份运行cmd,输入如下命令 bcdboot c:\windows / ...