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 696. [IOI1996][USACO 2.3] 最长前缀
★ 输入文件:prefix.in 输出文件:prefix.out 简单对比时间限制:1 s 内存限制:128 MB 描述 USACO 2.3.1 IOI96 在生物学中,一些生物的结构 ...
- (六)maven之本地仓库
本地仓库 ① 运行机制: 当用户在pom.xml文件中添加依赖jar包时,maven会先从本地仓库查找,如果这个jar包在本地仓库中找不到,就从中央仓库下载到本地仓库,中央仓库是maven默认 ...
- scanf("%s",s)与gets(s)
#include <stdio.h> void fun(char s[]) {; while(s[i]!='\0') {i++;} printf("%d",i);} v ...
- vue 数组更新 this.$set(this.dataList, data.index, data.data)
vue 数组更新 this.$set(this.dataList, data.index, data.data) https://www.cnblogs.com/huangenai/p/9836811 ...
- Windows server 2012安装oracle11g(32/64位)步骤
Oracle官方下地址: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html以下两网址 ...
- false - (失败的)什么都不做
总览 (SYNOPSIS) false [忽略命令行参数] false OPTION 描述 (DESCRIPTION) 程序 结束 时, 产生 表示 失败 的 状态码. 下列的 选项 没有 简写 形式 ...
- Java创建图片文件缩略图
public static void uploadImg(InputStream file, String filePath, String fileName, int widthdist, int ...
- Linux关于FTP安全
https://www.cnblogs.com/Hyber/archive/2017/02/04/6362916.htmlhttps://www.cnblogs.com/ichunqiu/p/7300 ...
- css去除链接 input 虚框
/* css去掉虚框 */ :focus{-webkit-outline-style:none;-moz-outline-style:none;-ms-outline-style:none;-o-ou ...
- OJ 大整数减法
描述 求两个大的正整数相减的差. 输入 共2行,第1行是被减数a,第2行是减数b(a > b).每个大整数不超过200位,不会有多余的前导零. 输出 一行,即所求的差. 样例输入 9999999 ...