BZOJ 4475: [Jsoi2015]子集选取

来源:互联网 发布:阿里云业务经理待遇 编辑:程序博客网 时间:2024/05/22 05:09

Description

这里写图片描述

Input

输入包含一行两个整数N和K,1<=N,K<=10^9

Output

一行一个整数,表示不同方案数目模1,000,000,007的值。

Sample Input

2 2

Sample Output

16

分析

我们通过找规律可以发现 答案为:2km
证明的话,我们设f[k]为大小为k的三角形的方案数,那么

f[k]=(i=1n1f[ki])+1

同数学归纳法可证

代码

#include <bits/stdc++.h>#define MOD 1000000007 #define ll long longll pow(ll x,ll y){    ll res = 1;    while (y)    {        if (y & 1)            res = res * x % MOD;        x = x * x % MOD;        y >>= 1;    }    return res;}int main(){    ll n,k;    scanf("%lld%lld",&n,&k);    printf("%lld\n",pow(2,n * k));}
0 0