QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#361245#7954. Special NumbersSolitaryDreamWA 79ms1631384kbC++171.5kb2024-03-23 01:02:342024-03-23 01:02:35

Judging History

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

  • [2024-03-23 01:02:35]
  • 评测
  • 测评结果:WA
  • 用时:79ms
  • 内存:1631384kb
  • [2024-03-23 01:02:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

const int P=1e9+7;

int f[22][2][2][61][42][42][22];

string l,r;

int k;

__int128 pw[11][70];

int dp(int x,int lead,int dw,int up,int c2,int c3,int c5,int c7)
{
    if(x==r.size())
    {
        if(c7==22)
            return 1;
        __int128 w=pw[2][c2]%k*pw[3][c3]%k*pw[5][c5]%k*pw[7][c7]%k;
        return !w;
    }
    if(f[x][lead][up][c2][c3][c5][c7]!=-1)
        return f[x][lead][up][c2][c3][c5][c7];
    int &ret=f[x][lead][up][c2][c3][c5][c7];
    ret=0;
    for(int i=(dw?l[x]-'0':0);i<=(up?r[x]-'0':9);i++)
    {
        int w=i;
        int nlead=lead&&i==0;
        int ndw=dw&&i==l[x]-'0';
        int nup=up&&i==r[x]-'0';
        int nc2=c2,nc3=c3,nc5=c5,nc7=c7;
        if(!nlead)
        {
            if(!i||nc7==22)
                nc2=nc3=nc5=nc7=22;
            else
            {
                while(w%2==0)
                    nc2++,w/=2;
                while(w%3==0)
                    nc3++,w/=3;
                while(w%5==0)
                    nc5++,w/=5;
                while(w%7==0)
                    nc7++,w/=7;
            }
        }
        ret+=dp(x+1,nlead,ndw,nup,nc2,nc3,nc5,nc7);
    }
    return ret%=P;
}

signed main()
{
    cin>>k>>l>>r;
    while(l.size()<r.size())
        l='0'+l;
    for(int i=1;i<=9;i++)
    {
        pw[i][0]=1;
        for(int j=1;j<=60;j++)
            pw[i][j]=pw[i][j-1]*i%k;
    }
    memset(f,-1,sizeof(f));
    cout<<dp(0,1,1,1,0,0,0,0)<<"\n";
}

详细

Test #1:

score: 100
Accepted
time: 59ms
memory: 1631128kb

input:

5 1 20

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 52ms
memory: 1631144kb

input:

5 50 100

output:

19

result:

ok single line: '19'

Test #3:

score: 0
Accepted
time: 43ms
memory: 1631152kb

input:

15 11 19

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 31ms
memory: 1631384kb

input:

1 100 100000

output:

99901

result:

ok single line: '99901'

Test #5:

score: 0
Accepted
time: 79ms
memory: 1631096kb

input:

1 1 1

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 56ms
memory: 1631148kb

input:

10 800 43021

output:

23570

result:

ok single line: '23570'

Test #7:

score: 0
Accepted
time: 76ms
memory: 1631156kb

input:

1125899906842624 1 100000000000000000000

output:

555058180

result:

ok single line: '555058180'

Test #8:

score: -100
Wrong Answer
time: 76ms
memory: 1630984kb

input:

187500000 5941554024261918062 17356601866920567143

output:

812969085

result:

wrong answer 1st lines differ - expected: '679191360', found: '812969085'