QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#67838#5192. 赌徒问题alpha1022AC ✓131ms195276kbC++232.0kb2022-12-12 15:54:572022-12-12 15:54:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-12 15:54:58]
  • 评测
  • 测评结果:AC
  • 用时:131ms
  • 内存:195276kb
  • [2022-12-12 15:54:57]
  • 提交

answer

#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=0;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=1:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?-n:n;
	}
	long long G()
	{
		long long n=0,F=0;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=1:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?-n:n;
	}
}
const int M=1000000007;
int f[2222][11][2222];
int p[777],pp;
class Init
{
    int v[2222];
    public:
    Init()
    {
        const int N=2000;
        for(int i=2;i<=N;++i)
        {
            if(!v[i])v[i]=++pp,p[pp]=i;
            for(int j=1;j<=v[i]&&i*p[j]<=N;++j)
                v[i*p[j]]=j;
        }
    }
}INIT;
std::bitset<2222> d[2222];
int main()
{
	int n=io::F(),m=io::F();
    long long k=io::F();
    f[1][0][0]=1;
    for(int i=1;i<=k&&i<=m;++i)
        if(k%i==0)
        {
            for(int x=0;x<n;++x)
                for(int j=0;j+i<=m;++j)
                    f[1][x+1][j+i]=(f[1][x+1][j+i]+f[1][x][j])%M;
        }
    for(int i=1;i<=m;++i)
        for(int j=1;j<=m;++j)
            if(i*k%j==0)d[i].set(j);
    for(int i=2;i<=m;++i)
    {
        long long min=m,mp;
        for(int j=1;j<=pp&&p[j]<=i;++j)
            if(i%p[j]==0)
            {
                int tmp=(d[i]^d[i/p[j]]).count();
                if(cmin(min,tmp))mp=p[j];
            }
        memcpy(f[i],f[i/mp],sizeof(f[i]));
        int (*F)[2222]=f[i];
        for(int v=1;v<=m;v++)
            if(d[i][v]&&!d[i/mp][v])
                for(int x=0;x<n;++x)
                    for(int j=0;j+v<=m;++j)
                        F[x+1][j+v]=(F[x+1][j+v]+F[x][j])%M;
    }
    int ans=0;
    for(int i=1;i<=m;++i)
    {
        //printf("%d\n",f[i][n][i]);
        ans=(ans+f[i][n][i])%M;
    }
    printf("%d\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3684kb

input:

1 1 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

1 1 20211123

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 32ms
memory: 67220kb

input:

1 666 65300

output:

666

result:

ok single line: '666'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3748kb

input:

9 1 12563478

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 89ms
memory: 195028kb

input:

8 2000 1

output:

670025

result:

ok single line: '670025'

Test #6:

score: 0
Accepted
time: 96ms
memory: 195216kb

input:

10 2000 440000000

output:

406465496

result:

ok single line: '406465496'

Test #7:

score: 0
Accepted
time: 124ms
memory: 193508kb

input:

10 1983 994593600

output:

403639064

result:

ok single line: '403639064'

Test #8:

score: 0
Accepted
time: 127ms
memory: 195036kb

input:

9 2000 821620800

output:

280647604

result:

ok single line: '280647604'

Test #9:

score: 0
Accepted
time: 114ms
memory: 195276kb

input:

10 2000 908107200

output:

991344753

result:

ok single line: '991344753'

Test #10:

score: 0
Accepted
time: 110ms
memory: 194880kb

input:

10 1997 616215600

output:

957863888

result:

ok single line: '957863888'

Test #11:

score: 0
Accepted
time: 131ms
memory: 195072kb

input:

10 1999 898405200

output:

681280074

result:

ok single line: '681280074'

Test #12:

score: 0
Accepted
time: 125ms
memory: 195048kb

input:

10 2000 20210526

output:

100160322

result:

ok single line: '100160322'

Test #13:

score: 0
Accepted
time: 106ms
memory: 195276kb

input:

10 2000 950965721

output:

14040666

result:

ok single line: '14040666'

Test #14:

score: 0
Accepted
time: 100ms
memory: 194936kb

input:

10 1998 944303559

output:

394435476

result:

ok single line: '394435476'