Submission #1794378


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
vector<int> makePrimes(int n) {
    vector<int> res, primes(n + 1, 1);
    primes[0] = primes[1] = 0;
    rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++) primes[i * (j + 2)] = 0;
    rep(i, 2, n + 1) if (primes[i]) res.push_back(i);
    return res;
}
bool isprime(int v) {
    if (v == 1) return false;
    for (int i = 2; 1LL * i*i <= v; i++) if (v%i == 0) return false;
    return true;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/



int L, R;
int A[1010101];
int cnt[1010101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> L >> R;

    vector<int> primes = makePrimes(40101);

    rep(i, L, R + 1) A[i - L] = i;
    fore(p, primes) {
        for (int l = (L + p - 1) / p * p; l <= R; l += p) {
            while (A[l - L] % p == 0) A[l - L] /= p, cnt[l - L]++;
        }
    }

    rep(i, 0, R - L + 1) if (1 < A[i]) cnt[i]++;
    int ans = 0;
    rep(i, 0, R - L + 1) {
        if (isprime(cnt[i]) and 0 < cnt[i]) ans++;
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Prime-Factor Prime
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1999 Byte
Status AC
Exec Time 50 ms
Memory 8160 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 2400 KB
00_sample_01 AC 2 ms 2400 KB
00_sample_02 AC 4 ms 4576 KB
00_sample_03 AC 2 ms 2400 KB
00_sample_04 AC 7 ms 4832 KB
00_sample_05 AC 50 ms 8160 KB
10_small_00 AC 2 ms 2400 KB
10_small_01 AC 2 ms 2400 KB
10_small_02 AC 2 ms 2400 KB
10_small_03 AC 2 ms 2400 KB
10_small_04 AC 2 ms 2400 KB
10_small_05 AC 2 ms 2400 KB
10_small_06 AC 2 ms 2400 KB
10_small_07 AC 2 ms 2400 KB
10_small_08 AC 2 ms 2400 KB
10_small_09 AC 2 ms 2400 KB
20_medium_00 AC 9 ms 5088 KB
20_medium_01 AC 34 ms 7008 KB
20_medium_02 AC 27 ms 6496 KB
20_medium_03 AC 16 ms 5600 KB
20_medium_04 AC 31 ms 6752 KB
20_medium_05 AC 22 ms 6240 KB
20_medium_06 AC 42 ms 7776 KB
20_medium_07 AC 14 ms 5472 KB
20_medium_08 AC 40 ms 7520 KB
20_medium_09 AC 6 ms 4704 KB
30_medium_00 AC 43 ms 7776 KB
30_medium_01 AC 21 ms 5984 KB
30_medium_02 AC 30 ms 6752 KB
30_medium_03 AC 26 ms 6496 KB
30_medium_04 AC 41 ms 7648 KB
30_medium_05 AC 26 ms 6496 KB
30_medium_06 AC 29 ms 6624 KB
30_medium_07 AC 10 ms 5088 KB
30_medium_08 AC 13 ms 5344 KB
30_medium_09 AC 37 ms 7136 KB
40_one_00 AC 2 ms 2400 KB
40_one_01 AC 2 ms 2400 KB
40_one_02 AC 2 ms 2400 KB
50_large_low_00 AC 48 ms 8160 KB
50_large_low_01 AC 49 ms 8160 KB
50_large_low_02 AC 49 ms 8160 KB
50_large_low_03 AC 49 ms 8160 KB
50_large_low_04 AC 49 ms 8160 KB
60_large_high_00 AC 49 ms 8160 KB
60_large_high_01 AC 49 ms 8160 KB
60_large_high_02 AC 49 ms 8160 KB
60_large_high_03 AC 49 ms 8160 KB
60_large_high_04 AC 49 ms 8160 KB
70_max_low_00 AC 49 ms 8160 KB
70_max_low_01 AC 49 ms 8160 KB
70_max_low_02 AC 49 ms 8160 KB
70_max_low_03 AC 50 ms 8160 KB
70_max_low_04 AC 50 ms 8160 KB
80_max_high_00 AC 49 ms 8160 KB
80_max_high_01 AC 50 ms 8160 KB
80_max_high_02 AC 50 ms 8160 KB
80_max_high_03 AC 49 ms 8160 KB
80_max_high_04 AC 49 ms 8160 KB