QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#473923 | #2568. Mountains | BINYU | WA | 0ms | 5916kb | C++14 | 1.5kb | 2024-07-12 15:02:20 | 2024-07-12 15:02:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const int N = 100,M = 1e5;
int n,m,k;
ll f[M + 5] = {1,1},inv[M + 5] = {1,1},invf[M + 5] = {1,1};
struct Matrix
{
int n;
ll a[N + 5][N + 5],ans;
void write()
{
for(int i = 1;i <= n;i++,puts(""))
for(int j = 1;j <= n;j++)
cout<<a[i][j]<<" ";puts("");
}
void clear()
{
for(int i = 1;i <= n;i++)
for(int j = 1;j <= n;j++)
a[i][j] = 0;
n = 0;
}
void Swap(int i,int j)
{
for(int k = 1;k <= n;k++)
swap(a[i][k],a[j][k]);
}
void add(int i,int j,ll v)
{
(v += mod) %= mod;
for(int k = 1;k <= n;k++)
(a[i][k] += a[j][k] * v) %= mod;
}
void update(int i,int j)
{
while(a[j][i] != 0)
add(i,j,-a[i][i] / a[j][i]),
Swap(i,j),(ans *= mod - 1) %= mod;
}
ll det()
{
ans = 1;
for(int i = 1;i <= n;(ans *= mod + a[i][i]) %= mod,i++)
for(int j = n;j > i;j--)update(i,j);
return ans;
}
}a;
ll C(ll n,ll m)
{
if(n < 0||m < 0||n < m)return 0;
return f[n] * invf[m] % mod * invf[n - m] % mod;
}
ll solve(int sx,int sy,int ex,int ey)
{
if(sx < ex||ey < sy)return 0;
return C(sx - ex + ey - sy,sx - ex);
}
int main()
{
scanf("%d %d %d",&n,&m,&k);
k++;
for(int i = 2;i <= M;i++)
f[i] = f[i - 1] * i % mod,
inv[i] = inv[mod % i] * (mod - mod / i) % mod,
invf[i] = invf[i - 1] * inv[i] % mod;
a.n = k;
for(int i = 1;i <= k;i++)
for(int j = 1;j <= k;j++)
a.a[i][j] = solve(n + i - 1,i,j,m + j - 1);
cout<<a.det();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5916kb
input:
1 1 1
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'