HihoCoder
来源:互联网 发布:好的南方二本院校知乎 编辑:程序博客网 时间:2024/06/06 12:31
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>#include <bitset>#define INF 0x3f3f3f3f#define eps 1e-6#define PI 3.1415926#define mod 1000000007#define base 2333using namespace std;typedef long long LL;const int inf = 1e9;const int maxn = 5e4 + 10;const int maxx = 1e3 + 10;int t, n, k;LL c[110][110], pre[maxn][110], pp[maxn][110];char str[maxn];void init() { memset(c, 0, sizeof(c)); for(int i = 0; i < 110; i++) c[i][0] = c[i][i] = 1; for(int i = 1; i < 110; i++) { for(int j = 1; j < i; j++) c[i][j] = (c[i-1][j-1]+c[i-1][j])%mod; } for(int i = 0; i < maxn; i++) pre[i][0] = pp[i][0] = 1;}void solve() { init(); scanf("%d", &t); while(t--) { scanf("%d%d%s", &n, &k, str+1); for(int i = 1; i <= n; i++) { pre[i][1] = (pre[i-1][1]+str[i]-'0')%mod; for(int j = 2; j <= k; j++) pre[i][j] = pre[i][j-1]*pre[i][1]%mod; } for(int i = 1; i <= n; i++) { for(int j = 0; j <= k; j++) pp[i][j] = (pp[i-1][j]+pre[i][j])%mod; } for(int i = 1; i <= n; i++) { LL ans = 0; for(int j = 0; j <= k; j++) { if((k-j)%2 == 0) ans = (ans+c[k][j]*pre[i][j]%mod*pp[i-1][k-j]%mod+mod)%mod; else ans = (ans-c[k][j]*pre[i][j]%mod*pp[i-1][k-j]%mod+mod)%mod; } if(i == n) printf("%lld\n", ans); else printf("%lld ", ans); } }}int main() { //srand(time(NULL)); //freopen("kingdom.in","r",stdin); //freopen("kingdom.out","w",stdout); solve();}
阅读全文
1 0
- hihocoder:
- hihoCoder
- Hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- hihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- ubuntu搭建svn服务器
- 抽象类的定义及运用
- 2017.8.12在线笔试编程真题总结
- c++字符串string操作全解
- 模拟模拟交易系统(三)——UI设计
- HihoCoder
- 线段树总结(点修改+区间修改)
- React实战-React中this的用法
- 强大的在线编辑器 Tower 开源Simditor
- 程序员必备单词3
- 朱刘算法(Directed Minimum Spanning Tree/Directed MST/Minimum Arborescence/Optimum Branchings)
- day_04_资源和图像、目录和定时器、鼠标和键盘
- shell脚本之简介
- Android 实现雪花飘落特效 安卓实现雪花 玫瑰 星星飘落