Submission #25258605


Source Code Expand

#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define WT int TT=read();while(TT--) 
#define NO puts("NO");
#define YES puts("YES");
using namespace std;

inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

const int Mod=924844033;
const int M=2010;
int fac[M],ifac[M],n,k,tmp[M],ans[M],sz,a2[M];

int poww(int a,int b)
{
	int res=1;
	while(b)
	{
		if (b&1)res=res*a%Mod;
		a=a*a%Mod,b>>=1;
	}return res;
}
int inv(int x){return poww(x,Mod-2);}
void init(int n)
{
	fac[0]=ifac[0]=1;
	for (int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%Mod,
		ifac[i]=inv(fac[i]);
}
int C(int m,int n)
{
	if (m<0||n<0||m<n)return 0;
	return fac[m]*ifac[n]%Mod*ifac[m-n]%Mod;
}

signed main()
{
	n=read(),k=read();init(n);ans[0]=1,sz=0;
	for (int w=1;w<=2*k;w++)
	{
		int s1=(n-(w>k?w-k:w))/k+1;
		memset(tmp,0,sizeof(tmp));
		for (int i=0;i<=s1/2;i++)a2[i]=C(s1-i,i);
		for (int i=0;i<=sz;i++)
			for (int j=0;j<=s1/2;j++)
				tmp[i+j]=(tmp[i+j]+ans[i]*a2[j])%Mod;
		sz+=s1/2;for (int i=0;i<=sz;i++)ans[i]=tmp[i];
	}int res=0;
	for (int i=0;i<=n;i++)res=(res+ans[i]*poww(Mod-1,i)%Mod*fac[n-i])%Mod;
	cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - ~K Perm Counting
User pigstd
Language C++ (GCC 9.2.1)
Score 900
Code Size 1374 Byte
Status AC
Exec Time 15 ms
Memory 3640 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 5
AC × 28
Set Name Test Cases
Sample example0, example1, example2, example3, example4
All example0, example1, example2, example3, example4, handmade0, handmade1, handmade2, handmade3, handmade4, handmade5, handmade6, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, rand0, rand1, rand2, rand3, rand4, small0, small1, small2, supersmall0, supersmall1, supersmall2
Case Name Status Exec Time Memory
example0 AC 8 ms 3448 KiB
example1 AC 2 ms 3476 KiB
example2 AC 2 ms 3560 KiB
example3 AC 2 ms 3560 KiB
example4 AC 2 ms 3464 KiB
handmade0 AC 4 ms 3452 KiB
handmade1 AC 7 ms 3632 KiB
handmade2 AC 5 ms 3472 KiB
handmade3 AC 5 ms 3640 KiB
handmade4 AC 4 ms 3500 KiB
handmade5 AC 13 ms 3632 KiB
handmade6 AC 10 ms 3632 KiB
maxrand0 AC 12 ms 3624 KiB
maxrand1 AC 15 ms 3432 KiB
maxrand2 AC 13 ms 3512 KiB
maxrand3 AC 7 ms 3480 KiB
maxrand4 AC 8 ms 3504 KiB
rand0 AC 13 ms 3484 KiB
rand1 AC 6 ms 3472 KiB
rand2 AC 4 ms 3492 KiB
rand3 AC 2 ms 3480 KiB
rand4 AC 12 ms 3592 KiB
small0 AC 3 ms 3640 KiB
small1 AC 3 ms 3568 KiB
small2 AC 4 ms 3484 KiB
supersmall0 AC 2 ms 3448 KiB
supersmall1 AC 3 ms 3448 KiB
supersmall2 AC 2 ms 3632 KiB