牛客网暑期ACM多校训练营 第九场
study from : https://blog.csdn.net/mitsuha_/article/details/81774727
k较小。分离x和k。



另外的可能:求a[k][x],x不确定,想到的是求sum(a[k][1]+a[k][2]+...+a[k][x]),树状数组 sum(x)-sum(x-1)。这题用不上。
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iostream>
using namespace std; #define ll long long const int maxn=1e5+;
const int maxk=+;
const int inf=1e9;
const ll mod=1e9+;
const double eps=1e-; ll f[maxk][maxn],mul[maxn],chu[maxn];
int n,k; ll C(int x,int y)
{
if (x<)
{
x=y--x;
return (y&?-:)*mul[x]*chu[x-y]%mod*chu[y]%mod;
}
if (x<y)
return ;
return mul[x]*chu[x-y]%mod*chu[y]%mod;
} ll _pow(ll a,ll b)
{
ll y=;
while (b)
{
if (b &)
y=y*a%mod;
a=a*a%mod;
b>>=;
}
return y;
} void update(int x,ll y,int j)
{
while (x<=n)
{
f[j][x]=(f[j][x]+y)%mod;
x+=x&-x;
}
} ll cal(int x,int j)
{
ll sum=;
while (x)
{
sum=(sum+f[j][x])%mod;
x-=x&-x;
}
return sum;
} int main()
{
int m,i,j,mode,x;
ll sum=,y;
scanf("%d%d%d",&n,&m,&k);
k--;
mul[]=;
for (i=;i<=n;i++)
mul[i]=mul[i-]*i%mod;
chu[n]=_pow(mul[n],mod-);
for (i=n-;i>=;i--)
chu[i]=chu[i+]*(i+)%mod;
while (m--)
{
scanf("%d",&mode);
if (mode)
{
scanf("%d",&x);
sum=;
for (j=;j<=k;j++)
sum=(sum+C(x,j)*cal(x,j))%mod;
printf("%lld\n",sum);
}
else
{
scanf("%d%lld",&x,&y);
for (j=;j<=k;j++)
update(x,C(k-x,k-j)*y%mod,j);
}
}
return ;
}
/*
4 11 3
0 3 1
1 4
*/
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iostream>
using namespace std; #define ll long long const int maxn=1e5+;
const int inf=1e9;
const double eps=1e-;
const ll mod=1e9+; ll mul[maxn<<],chu[maxn<<]; ll _pow(ll a,ll b)
{
ll y=;
while (b)
{
if (b&)
y=y*a%mod;
a=a*a%mod;
b>>=;
}
return y;
} ll C(ll x,ll y)
{
return mul[x]*chu[x-y]%mod*chu[y]%mod;
} int main()
{
int n,i,j,a;
scanf("%d",&n);
mul[]=;
for (i=;i<=*n;i++)
mul[i]=mul[i-]*i%mod;
chu[*n]=_pow(mul[*n],mod-);
for (i=*n-;i>=;i--)
chu[i]=chu[i+]*(i+)%mod;
i=,j=;
while (~scanf("%d",&a))
{
printf("%lld\n",_pow(,+i+j)*C(*n--i-j,n-i-)%mod);
i+=(a==),j+=(a==);
}
return ;
}
/* */
牛客网暑期ACM多校训练营 第九场的更多相关文章
- 牛客网暑期ACM多校训练营(第四场):A Ternary String(欧拉降幂)
链接:牛客网暑期ACM多校训练营(第四场):A Ternary String 题意:给出一段数列 s,只包含 0.1.2 三种数.每秒在每个 2 后面会插入一个 1 ,每个 1 后面会插入一个 0,之 ...
- 牛客网暑期ACM多校训练营(第五场):F - take
链接:牛客网暑期ACM多校训练营(第五场):F - take 题意: Kanade有n个盒子,第i个盒子有p [i]概率有一个d [i]大小的钻石. 起初,Kanade有一颗0号钻石.她将从第1到第n ...
- 牛客网 暑期ACM多校训练营(第二场)A.run-动态规划 or 递推?
牛客网暑期ACM多校训练营(第二场) 水博客. A.run 题意就是一个人一秒可以走1步或者跑K步,不能连续跑2秒,他从0开始移动,移动到[L,R]的某一点就可以结束.问一共有多少种移动的方式. 个人 ...
- 牛客网 暑期ACM多校训练营(第一场)A.Monotonic Matrix-矩阵转化为格子路径的非降路径计数,Lindström-Gessel-Viennot引理-组合数学
牛客网暑期ACM多校训练营(第一场) A.Monotonic Matrix 这个题就是给你一个n*m的矩阵,往里面填{0,1,2}这三种数,要求是Ai,j⩽Ai+1,j,Ai,j⩽Ai,j+1 ,问你 ...
- 牛客网暑期ACM多校训练营(第三场)H Diff-prime Pairs (贡献)
牛客网暑期ACM多校训练营(第三场)H Diff-prime Pairs (贡献) 链接:https://ac.nowcoder.com/acm/contest/141/H来源:牛客网 Eddy ha ...
- 2018牛客网暑期ACM多校训练营(第二场)I- car ( 思维)
2018牛客网暑期ACM多校训练营(第二场)I- car 链接:https://ac.nowcoder.com/acm/contest/140/I来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 ...
- 牛客网暑期ACM多校训练营(第七场)Bit Compression
链接:https://www.nowcoder.com/acm/contest/145/C 来源:牛客网 题目描述 A binary string s of length N = 2n is give ...
- 牛客网暑期ACM多校训练营(第一场) - J Different Integers(线段数组or莫队)
链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...
- 牛客网暑期ACM多校训练营(第九场) A题 FWT
链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...
随机推荐
- python学习笔记(9)--函数
函数定义: def <函数名>(<参数(0个或多个)>): 函数体 return <返回值> 参数有非可选参数,和可选参数,可选参数放在参数列表的最后,可以为可选参 ...
- iview render bug & vue namespace bug
iview render bug https://codepen.io/xgqfrms/pen/gyGjKP https://codepen.io/xgqfrms/full/gyGjKP bug &l ...
- 老男孩python学习自修第六天【pycharm的使用】
1.在工程右键可选新建文件夹,包盒python文件 文件夹和包的区别在于,包包含一个空的__init__.py文件,而文件夹没有 2.pycharm的断点调试 点击Debug表示进入调试状态 点击Re ...
- vue起步和模板語法
vue構造器里有哪些內容: var a=new Vue({}) 模板語法: 文本插值: html: html的屬性里的值應該使用v-bind: 表達式: 指令; 參數:v-bind,v-on 雙向用戶 ...
- File类 详解!
package cn.zhoucufeng; import java.io.File; import java.io.IOException; import java.util.Arrays; imp ...
- hdu-6166(最短路+二进制分组)
题意:给你n个点m条边的有向图,然后再给你k个不同的点,问你这k个点的最小距离: 解题思路:这道题最需要注意的就是k个点一定是不同的,那么有一个结论就是任意两个不同的数字中,在他们的二进制地表示中,一 ...
- .net mvc 基类属性覆盖问题
一,问题是这样的 我使用.net mvc设计架构时, 为了方便大家的获取UserInfo信息, 把UserInfo对象,放在了自定义的基类BaseController中, 二,问题出现了 我发觉多个人 ...
- windows 环境下通过运行快速启动程序
在windows环境下,我们可以使用一些系统内置的快捷键来快速启动我们想要的应用程序,我这里举例几个我经常使用的,比如: 快捷键 功能说明 services.msc 查看系统服务 gpedit.ms ...
- F. Asya And Kittens 并查集维护链表
reference :https://www.cnblogs.com/ZERO-/p/10426473.html
- 使用tree命令导出文件夹/文件的目录树
前提:己安装扩展: 介绍: TREE [drive:][path] [/F] [/A] /F 显示每个文件夹中文件的名称.(带扩展名) /A 使用 ASCII 字符,而不使用扩展字符. t ...