Matrix
来源:互联网 发布:天子网络 编辑:程序博客网 时间:2024/05/17 23:36
Description
Input
Output
Sample Input
4 3 5
4 1 7 3
4 7 4 8
Sample Output
59716
Data Constraint
Solution
Code
const mo=1000000007;var n,i:longint; ans,t,k,x,y:int64; c,a,b,l,r:array[0..100005] of int64;function ni(x:int64):int64;var y,ans:int64;begin y:=mo-2; ans:=1; while y<>0 do begin if y mod 2=1 then ans:=ans*x mod mo; x:=x*x mod mo; y:=y div 2; end; exit(ans);end;begin readln(n,a[1],b[1]); dec(n); for i:=n downto 0 do read(r[i]);readln; for i:=n downto 0 do read(l[i]); k:=1;t:=1; while k<n do begin t:=t*k mod mo; k:=k+1; end; x:=1;y:=t*n mod mo; c[0]:=1;c[1]:=n; for i:=2 to n-1 do begin x:=x*i mod mo; y:=y*(i+n-1) mod mo; c[i]:=y*ni(t*x mod mo) mod mo; end; a[0]:=1;b[0]:=1; for i:=2 to n do begin a[i]:=a[i-1]*a[1] mod mo; b[i]:=b[i-1]*b[1] mod mo; end; for i:=0 to n-1 do begin ans:=(ans+c[i]*l[i] mod mo *a[i] mod mo*b[n] mod mo) mod mo; ans:=(ans+c[i]*r[i] mod mo *a[n] mod mo*b[i] mod mo) mod mo; end; writeln(ans);end.
1 0
- 《Matrix》
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- mAtrix
- Matrix
- matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- 2016.08.18【初中部 NOIP普及组 】模拟赛
- xenserver 恢复从pool中删除的机器状态
- bug-Gallery2-menu-No1-20160818
- coding.net项目管理
- Bootstrap 关于背景图像的自适应和行的栅格化
- Matrix
- poj 1905
- echarts图表showLoading遮盖层显示问题
- 每日一记-防止重复提交
- jzoj 2050. 【8.18】游戏
- C++笔记
- codechef SHORT
- Ubuntu中更改所有子文件和子目录所有者权限
- Adding Animations之Animating Layout Changes