Submission #3873345


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
int prime[100000];
bool is_prime[100001];
int sieve(int n){
    int p = 0;
    rep(i,0,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,n+1){
        if (is_prime[i]){
            p++;
            prime[p]=i;
            for (int j=2*i; j<=n; j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int d[1000010];
ll n[1000010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l,r;
    cin>>l>>r;
    int c=sieve(int(sqrt(r)));
    rep(i,0,r-l+1){
        n[i]=i+l;
    }
    rep(j,1,c+1){
        ll i=(l+prime[j]-1)/prime[j]*prime[j];
        while(i<=r){
            while(n[i-l]%prime[j]==0){
                d[i-l]++;
                n[i-l]/=prime[j];
            }
            i+=prime[j];
        }
    }
    rep(i,0,r-l+1){
        if(n[i]!=1) d[i]++;
    }
    ll ans=0;
    rep(i,0,r-l+1){
        if(is_prime[d[i]]) ans++;
    }
    cout<<ans<<"\n";
}

Submission Info

Submission Time
Task C - Prime-Factor Prime
User yuki1997
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1150 Byte
Status AC
Exec Time 142 ms
Memory 12032 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 59
Set Name Test Cases
All 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03, 00_sample_04, 00_sample_05, 10_small_00, 10_small_01, 10_small_02, 10_small_03, 10_small_04, 10_small_05, 10_small_06, 10_small_07, 10_small_08, 10_small_09, 20_medium_00, 20_medium_01, 20_medium_02, 20_medium_03, 20_medium_04, 20_medium_05, 20_medium_06, 20_medium_07, 20_medium_08, 20_medium_09, 30_medium_00, 30_medium_01, 30_medium_02, 30_medium_03, 30_medium_04, 30_medium_05, 30_medium_06, 30_medium_07, 30_medium_08, 30_medium_09, 40_one_00, 40_one_01, 40_one_02, 50_large_low_00, 50_large_low_01, 50_large_low_02, 50_large_low_03, 50_large_low_04, 60_large_high_00, 60_large_high_01, 60_large_high_02, 60_large_high_03, 60_large_high_04, 70_max_low_00, 70_max_low_01, 70_max_low_02, 70_max_low_03, 70_max_low_04, 80_max_high_00, 80_max_high_01, 80_max_high_02, 80_max_high_03, 80_max_high_04
Case Name Status Exec Time Memory
00_sample_00 AC 2 ms 2304 KB
00_sample_01 AC 2 ms 2304 KB
00_sample_02 AC 7 ms 2816 KB
00_sample_03 AC 2 ms 2304 KB
00_sample_04 AC 12 ms 5120 KB
00_sample_05 AC 121 ms 12032 KB
10_small_00 AC 2 ms 2304 KB
10_small_01 AC 2 ms 2304 KB
10_small_02 AC 2 ms 2304 KB
10_small_03 AC 2 ms 2304 KB
10_small_04 AC 2 ms 2304 KB
10_small_05 AC 2 ms 2304 KB
10_small_06 AC 2 ms 2304 KB
10_small_07 AC 2 ms 2304 KB
10_small_08 AC 2 ms 2304 KB
10_small_09 AC 2 ms 2304 KB
20_medium_00 AC 16 ms 5632 KB
20_medium_01 AC 72 ms 10752 KB
20_medium_02 AC 57 ms 10496 KB
20_medium_03 AC 32 ms 8448 KB
20_medium_04 AC 63 ms 10624 KB
20_medium_05 AC 45 ms 8448 KB
20_medium_06 AC 88 ms 11648 KB
20_medium_07 AC 30 ms 8448 KB
20_medium_08 AC 83 ms 11392 KB
20_medium_09 AC 10 ms 2944 KB
30_medium_00 AC 90 ms 11520 KB
30_medium_01 AC 42 ms 8448 KB
30_medium_02 AC 63 ms 10496 KB
30_medium_03 AC 54 ms 10496 KB
30_medium_04 AC 88 ms 11520 KB
30_medium_05 AC 53 ms 10496 KB
30_medium_06 AC 60 ms 10496 KB
30_medium_07 AC 20 ms 5760 KB
30_medium_08 AC 26 ms 6272 KB
30_medium_09 AC 77 ms 11008 KB
40_one_00 AC 2 ms 2304 KB
40_one_01 AC 2 ms 2304 KB
40_one_02 AC 2 ms 2304 KB
50_large_low_00 AC 101 ms 12032 KB
50_large_low_01 AC 107 ms 12032 KB
50_large_low_02 AC 109 ms 12032 KB
50_large_low_03 AC 110 ms 12032 KB
50_large_low_04 AC 111 ms 12032 KB
60_large_high_00 AC 111 ms 12032 KB
60_large_high_01 AC 111 ms 12032 KB
60_large_high_02 AC 109 ms 12032 KB
60_large_high_03 AC 109 ms 12032 KB
60_large_high_04 AC 106 ms 12032 KB
70_max_low_00 AC 108 ms 12032 KB
70_max_low_01 AC 113 ms 12032 KB
70_max_low_02 AC 123 ms 12032 KB
70_max_low_03 AC 116 ms 12032 KB
70_max_low_04 AC 118 ms 12032 KB
80_max_high_00 AC 142 ms 12032 KB
80_max_high_01 AC 117 ms 12032 KB
80_max_high_02 AC 121 ms 12032 KB
80_max_high_03 AC 115 ms 12032 KB
80_max_high_04 AC 112 ms 12032 KB