QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621553#4634. FactorCrysflyWA 533ms19312kbC++141.3kb2024-10-08 15:21:242024-10-08 15:21:25

Judging History

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

  • [2024-10-08 15:21:25]
  • 评测
  • 测评结果:WA
  • 用时:533ms
  • 内存:19312kb
  • [2024-10-08 15:21:24]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;

typedef vector<int>vi;
#define pb push_back

#define maxn 4000005
int pri[maxn],tot;
bool vis[maxn];

int sum[maxn];
void sieve(int n){
    vis[1]=1;
    For(i,2,n){
        if(!vis[i]){
            pri[++tot]=i;
        }
        For(j,1,tot){
            int x=i*pri[j];
            if(x>n)break;
            vis[x]=1;
            if(i%pri[j]==0)break;
        }
    }
    For(i,1,n) sum[i]=sum[i-1]+(!vis[i]);
}

int n,B;
int res;
void dfs(int u,int xs,int id){
    if(u>n) return;
    ++res;
  //  cout<<"add "<<u<<"\n";
    for(int i=id; i<=tot; ++i){
        if(u*pri[i]>n) break;
        if(pri[i]>xs+1) break;
        if(u*pri[i]*pri[i]>n){
            int r=min(xs+1,n/u);
            res+=sum[r]-sum[pri[i]-1];
            return;
        }
        int p=pri[i];
        int v=u,sv=1,pw=1;
        for(int j=1; ;++j){
            pw*=p;
            sv+=pw;
            v*=p;
            if(v>n)break;
            dfs(v,xs*sv,i+1);
        }
    }
}


signed main()
{
    cin>>n;
    B=sqrt(n)+1;
    sieve(1000005);
    dfs(1,1,1);
    cout<<res;
	return 0;
}

/*
1000000000000
50
1 2 4 6 8 12 16 18 20 24 28 30 32 36 40 42 48
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 17852kb

input:

10

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 7ms
memory: 14064kb

input:

20

output:

9

result:

ok single line: '9'

Test #3:

score: 0
Accepted
time: 4ms
memory: 18784kb

input:

50

output:

17

result:

ok single line: '17'

Test #4:

score: 0
Accepted
time: 3ms
memory: 16400kb

input:

6

output:

4

result:

ok single line: '4'

Test #5:

score: 0
Accepted
time: 7ms
memory: 14068kb

input:

87

output:

26

result:

ok single line: '26'

Test #6:

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

input:

609

output:

130

result:

ok single line: '130'

Test #7:

score: 0
Accepted
time: 8ms
memory: 19312kb

input:

5126

output:

806

result:

ok single line: '806'

Test #8:

score: 0
Accepted
time: 3ms
memory: 14336kb

input:

92180

output:

10905

result:

ok single line: '10905'

Test #9:

score: 0
Accepted
time: 4ms
memory: 17532kb

input:

984096

output:

95960

result:

ok single line: '95960'

Test #10:

score: 0
Accepted
time: 4ms
memory: 16056kb

input:

5744387

output:

494209

result:

ok single line: '494209'

Test #11:

score: 0
Accepted
time: 9ms
memory: 17860kb

input:

51133311

output:

3851066

result:

ok single line: '3851066'

Test #12:

score: 0
Accepted
time: 7ms
memory: 16424kb

input:

607519174

output:

40319008

result:

ok single line: '40319008'

Test #13:

score: 0
Accepted
time: 18ms
memory: 17644kb

input:

7739876803

output:

456270136

result:

ok single line: '456270136'

Test #14:

score: 0
Accepted
time: 85ms
memory: 18932kb

input:

80754680817

output:

4304423738

result:

ok single line: '4304423738'

Test #15:

score: -100
Wrong Answer
time: 533ms
memory: 14632kb

input:

1000000000000

output:

42772979260

result:

wrong answer 1st lines differ - expected: '48366248808', found: '42772979260'