QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750572#9612. 月亮的背面是粉红色的Nesraychan21 1439ms138008kbC++143.3kb2024-11-15 15:01:402024-11-15 15:01:41

Judging History

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

  • [2024-11-15 15:01:41]
  • 评测
  • 测评结果:21
  • 用时:1439ms
  • 内存:138008kb
  • [2024-11-15 15:01:40]
  • 提交

answer

#include<bits/stdc++.h>
#define IL inline
#define reg register
#define N 100000005
#define M 6000600
#define int long long
#define mod 1000000007
IL int read()
{
    reg int x=0,f=0; reg char ch=getchar();
    while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}

IL int Add(reg int x,reg int y){return x+y<mod?x+y:x+y-mod;}
IL int Sub(reg int x,reg int y){return x<y?x-y+mod:x-y;}
IL void Pls(reg int &x,reg int y){x=Add(x,y);}
IL void Pls(reg signed &x,reg int y){x=Add(x,y);}
IL void Dec(reg int &x,reg int y){x=Sub(x,y);}
IL int Mul(reg int x,reg int y){reg long long r=1ll*x*y; return r<mod?r:r%mod;}
IL int power(reg int x,reg int p){reg int r=1; for(;p;p>>=1,x=Mul(x,x))if(p&1)r=Mul(r,x); return r;}

const int inv2=mod+1>>1,B=1e8;
int n,m,pri[M],tot;
std::bitset<N>isp;

IL void sieve(reg int n)
{
    tot=0; 
    for(reg int i=2,j,v;i<=n;++i)
    {
        if(!isp[i])pri[++tot]=i;
        for(j=1;j<=tot&&(v=i*pri[j])<=n;++j)
        {
            isp[v]=1;
            if(i%pri[j]==0)break;
        }
    }
}

int ans0;
signed f0[N],g0[N];

IL void upd(reg int k0,reg int m)
{
    if(m<=B)Pls(f0[m],k0);
    else Pls(g0[n/m],k0);
}

void dfs(reg int i,reg int x,reg int f0)
{
    if(i>tot||pri[i]*pri[i]>x)
    {
        upd(f0,x);
        return;
    }
    dfs(i+1,x,f0);
    dfs(i+1,x/pri[i]/pri[i],mod-f0);
}

int c[M];
std::vector<std::tuple<int,int,int>>vec;

main()
{
    n=read(),m=read();
    reg int lim=1;
    while(lim*lim<=n)++lim;
    sieve(lim-1);
    vec.push_back({1,n,1});
    while(vec.size())
    {
        auto [i,x,f0]=vec.back();
        if(i>tot||pri[i]*pri[i]>x)
        {
            upd(f0,x),vec.pop_back();
            continue;
        }
        if(c[i]==2)
        {
            c[i]=0;
            vec.pop_back();
            continue;
        }
        if(c[i]==1)
        {
            c[i]=2;
            vec.push_back({i+1,x/pri[i]/pri[i],mod-f0});
        }else
        {
            c[i]=1;
            vec.push_back({i+1,x,f0});
        }
    }
    fprintf(stderr,"%.3lf\n",1.0*clock()/CLOCKS_PER_SEC);
    for(reg int x=1,m;x<=B;++x)if(f0[x])
    {
        m=x;
        reg int s0=0,i1=1,i2=2,i3=3,i4=4,i5=5,i6=6,i7=7,i8=8;
        while(i8*i8<=m)
        {
            s0+=m/i1,i1+=8;
            s0+=m/i2,i2+=8;
            s0+=m/i3,i3+=8;
            s0+=m/i4,i4+=8;
            s0+=m/i5,i5+=8;
            s0+=m/i6,i6+=8;
            s0+=m/i7,i7+=8;
            s0+=m/i8,i8+=8;
        }
        while(i1*i1<=m)s0+=m/i1,++i1;
        s0=(s0+s0-(i1-1)*(i1-1))%mod;
        Pls(ans0,Mul(s0,f0[x]));
    }
    for(reg int x=1,m;x<=B;++x)if(g0[x])
    {
        m=n/x;
        reg int s0=0,i1=1,i2=2,i3=3,i4=4,i5=5,i6=6,i7=7,i8=8;
        while(i8*i8<=m)
        {
            s0+=m/i1,i1+=8;
            s0+=m/i2,i2+=8;
            s0+=m/i3,i3+=8;
            s0+=m/i4,i4+=8;
            s0+=m/i5,i5+=8;
            s0+=m/i6,i6+=8;
            s0+=m/i7,i7+=8;
            s0+=m/i8,i8+=8;
        }
        while(i1*i1<=m)s0+=m/i1,++i1;
        s0=(s0+s0-(i1-1)*(i1-1))%mod;
        Pls(ans0,Mul(s0,g0[x]));
    }
    printf("%lld\n",power(ans0,2));
    fprintf(stderr,"%.3lf\n",1.0*clock()/CLOCKS_PER_SEC);
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 60ms
memory: 6072kb

input:

1726 1

output:

84290761

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 60ms
memory: 6140kb

input:

6116899 1

output:

219318963

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #3:

score: 8
Accepted

Test #7:

score: 8
Accepted
time: 64ms
memory: 7204kb

input:

6469467712 0

output:

147393348

result:

ok 1 number(s): "147393348"

Test #8:

score: 8
Accepted
time: 64ms
memory: 7308kb

input:

8967004453 0

output:

229436583

result:

ok 1 number(s): "229436583"

Test #9:

score: 8
Accepted
time: 64ms
memory: 7152kb

input:

6636594384 0

output:

995965072

result:

ok 1 number(s): "995965072"

Subtask #4:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 60ms
memory: 7280kb

input:

8292948816 1

output:

566765721

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #5:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 87ms
memory: 16488kb

input:

900472451132 1

output:

247050500

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #6:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 198ms
memory: 24168kb

input:

9864907300784 1

output:

359943536

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #7:

score: 13
Accepted

Test #19:

score: 13
Accepted
time: 486ms
memory: 55852kb

input:

96735749745529 0

output:

223354886

result:

ok 1 number(s): "223354886"

Test #20:

score: 13
Accepted
time: 482ms
memory: 55648kb

input:

95243570720799 0

output:

555372474

result:

ok 1 number(s): "555372474"

Test #21:

score: 13
Accepted
time: 485ms
memory: 55672kb

input:

97668723090105 0

output:

84562124

result:

ok 1 number(s): "84562124"

Subtask #8:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 466ms
memory: 57716kb

input:

94060593399194 1

output:

52991150

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements

Subtask #9:

score: 0
Time Limit Exceeded

Test #25:

score: 0
Time Limit Exceeded

input:

9772457586483846 0

output:


result:


Subtask #10:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 1439ms
memory: 138008kb

input:

949243849085176 1

output:

508465534

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements