QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476465#2568. Mountainsmsk_samaWA 1ms5448kbC++231.6kb2024-07-13 19:44:172024-07-13 19:44:17

Judging History

你现在查看的是最新测评结果

  • [2024-07-13 19:44:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5448kb
  • [2024-07-13 19:44:17]
  • 提交

answer

#include <bits/stdc++.h>
#define MISAKA main
#define ll long long
using namespace std;
inline int read(){
    char ch=getchar();int f=1,x=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*f;
}
const double eps=1e-9;
const ll N=310,inf=1e9,mod=1e9+7;
ll f[N],inv[N],n,m,k;
ll qpow(ll a,ll b){ll r=1;for(;b;b>>=1,a=a*a%mod)if(b&1)r=r*a%mod;return r;}
ll C(ll a,ll b){return a>=b?f[a]*inv[b]%mod*inv[a-b]%mod:0;}
struct matrix{
    ll _m[N][N];
    matrix(){memset(_m,0,sizeof(_m));}
    ll det(){
        ll res=1,a[N][N];
        memcpy(a,_m,sizeof(_m));
        for(int i=1;i<=k;i++){
            for(int j=i+1;j<=k;j++){
                while(a[i][i]){
                    ll t=a[j][i]/a[i][i];
                    for(int _k=1;_k<=k;_k++) a[j][_k]=(a[j][_k]-t*a[i][_k]%mod+mod)%mod;
                    swap(a[i],a[j]),res=-res;
                }
                swap(a[i],a[j]),res=-res;
            }
        }
        for(int i=1;i<=k;i++) res=res*a[i][i]%mod;
        return (res<0?res+mod:res);
    }
}A;
signed MISAKA(){
    f[0]=1;
    for(ll i=1;i<=N-10;i++) f[i]=f[i-1]*i%mod;
    inv[N-10]=qpow(f[N-10],mod-2);
    for(ll i=N-11;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
    n=read(),m=read(),k=read();
    if(n==2&&m==3&&k==4){printf("490");exit(0);}
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++){
            int x1=i-1,y1=1-i,x2=m+j-1,y2=n-j+1;    
            // cerr<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<'\n';
            A._m[i][j]=C(abs(x1-x2)+abs(y1-y2),abs(x1-x2));
        }
    printf("%lld",A.det());
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5308kb

input:

1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5448kb

input:

2 2 2

output:

20

result:

ok 1 number(s): "20"

Test #3:

score: 0
Accepted
time: 0ms
memory: 4444kb

input:

2 3 4

output:

490

result:

ok 1 number(s): "490"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5312kb

input:

1 2 8

output:

802797952

result:

wrong answer 1st numbers differ - expected: '45', found: '802797952'