8540: Ice Drinking

内存限制:512 MB 时间限制:10 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:1

题目描述

One day NIO was very thirsty, so he went to the ice-drinking room and ordered n different drinks, each with a unique ingredient.


The owner thought NIO's request was too weird, so he asked NIO, "How can you eat like this?" However, NIO just responded with "none of your business". The ice-drinking room owner was very angry, so he decided to add the n ingredients to NIO's n drink at random while ensuring that each cup of drink will have exactly one ingredient.


NIO discovered what the ice-drinking owner was trying to do. Given a natural number k, he wants to know in advance what the expected value of xk is, if we let x denote the number of cups with the correct ingredient.


Since Nio does not like fractions, he only wants to know the value of the result modulo 862118861.

输入格式

The only line of input contains two natural numbers n,k in order, where 1≤n≤1018, 0≤k≤n+5×103.

输出格式

Output a natural number in one line, denoting the answer modulo 862118861.

输入样例 复制

3 4

输出样例 复制

14

数据范围与提示

Let 1, 2, 3 denote the three ingredients. There are six possible results.

1 2 3: x=3,xk=81.
1 3 2, 2 1 3, 3 2 1: x=1,xk=1.
2 3 1, 3 1 2: x=0,xk=0.
Thus E(xk)=(81+3)/6=14.

分类标签