当前位置: 代码迷 >> 综合 >> Determinant
  详细解决方案

Determinant

热度:55   发布时间:2023-12-06 21:36:46.0

modulo  求余    determine 确定        determinant  n行列式 

the input consists of several test cases terminated by end-of-file

terminal n终端    terminate v终结      the sum of ... 总和

 

输出描述:

For each test case, print an integer which denotes the result.

示例1

输入

复制

2 1
0 0
0 0
2 1
1000000000 1000000000
1000000000 1000000000
3 2
2 3 3
2 3 3

输出

复制

1
99
96

 

#include<iostream>
using namespace std;
#define ll long long
#define li __int128
const int mod=1e9+7;
const int maxn=1e6+10;
ll n,x,a[maxn],b;int main(){while(cin>>n>>x){for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}ll ans=0;for(int i=1;i<=n;i++){scanf("%lld",&b);a[i]=(b*a[i])%mod;ans=(ans+a[i])%mod;}ans=(ans+x)%mod;for(int i=1;i<n;i++){ans=(ans*x)%mod;}printf("%lld\n",ans%mod);}	return 0;
}