Submission #41058025


Source Code Expand

/* InTheBloom_Template v1.04 (BETA) Last updated: 2023/4/25 */
/* Repository: https://github.com/InTheBloom/InTheBloom_Library */

/* Originally includes 'in_out.c', 'debug.c' */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define EPRINT_INT(x) {\
    long long Z = x;\
    fprintf(stderr, "Line %d: %s = %lld\n", __LINE__, #x, Z);\
}
#define EPRINT_STR(x) {\
    fprintf(stderr, "Line %d: %s = %s\n", __LINE__, #x, x);\
}
#define EPRINT_INT_ARRAY(x, n) do {\
    if (n > 0) {\
        fprintf(stderr, "Line %d: %s = [", __LINE__, #x);\
        for (int qq = 0; qq < n - 1; qq++) {\
            long long Z = x[qq];\
            fprintf(stderr, "%lld, ", Z);\
        }\
    long long Z = x[n - 1];\
    fprintf(stderr, "%lld]\n", Z);\
    } else {\
        fprintf(stderr, "[]\n");\
    }\
} while (0)

#define NEWLINE fprintf(stderr, "\n")

int read_int (void) {
    int x;
    scanf("%d", &x);
    return x;
}

double read_double (void) {
    double x;
    scanf("%lf", &x);
    return x;
}

long long read_long_long (void) {
    long long x;
    scanf("%lld", &x);
    return x;
}

void read_str (char *x) {
    scanf("%s", x);
}

void read_int_array (int *x, int n) {
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
}

void read_long_long_array (long long *x, int n) {
    for (int i = 0; i < n; i++) {
        scanf("%lld", &x[i]);
    }
}

// Defined with macros to support multiple types.

#define print_int_array_with_space(x, n) do {\
    for (int i = 0; i < n; i++) {\
        long long Z = x[i];\
        printf("%lld ", Z);\
    }\
    printf("\n");\
} while (0)

#define print_int_array_with_newlines(x, n) do {\
    for (int i = 0; i < n; i++) {\
        long long Z = x[i];\
        printf("%lld\n", Z);\
    }\
} while (0)

#define print_int(x) do {\
    long long Z = x;\
    printf("%lld\n", Z);\
} while (0)

void solve (long long N) {
    const int prime_sup = 1000000;
    bool prime[prime_sup];
    for (int i = 0; i < prime_sup; prime[i++] = true) {}
    prime[0] = prime[1] = false;

    { // エラトステネス
        int SUP = (int)sqrt(prime_sup);
        for (int i = 2; i < SUP + 10; i++) {
            for (int j = 2 * i; j < prime_sup; j += i) {
                prime[j] = false;
            }
        }
    }

    long long ans = 0;
    for (int i = 0; ; i++) {
        if (1000 < i) {
            break;
        }
        if (prime[i] == false) {
            continue;
        }
        for (int j = i + 1; ; j++) {
            if (prime[j] == false) {
                continue;
            }

            long long product = (long long)i * i * j * j;
            if (N < product) {
                break;
            }
            for (int k = i + 1; k < j; k++) {
                if (prime[k] == true) {
                    if (product * k <= N) {
                        ans++;
                    } else {
                        break;
                    }
                }
            }
        }
    }

    print_int(ans);
}

int main (void) {
    long long N = read_long_long();

    solve(N);

    return 0;
}

Submission Info

Submission Time
Task D - AABCC
User InTheBloom
Language C (Clang 10.0.0)
Score 400
Code Size 3281 Byte
Status AC
Exec Time 45 ms
Memory 3068 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 14 ms 2980 KiB
sample_02.txt AC 41 ms 3060 KiB
test_01.txt AC 11 ms 2944 KiB
test_02.txt AC 14 ms 3048 KiB
test_03.txt AC 13 ms 2972 KiB
test_04.txt AC 45 ms 2976 KiB
test_05.txt AC 43 ms 2940 KiB
test_06.txt AC 15 ms 2972 KiB
test_07.txt AC 34 ms 3068 KiB
test_08.txt AC 13 ms 2976 KiB
test_09.txt AC 44 ms 3068 KiB
test_10.txt AC 38 ms 2964 KiB
test_11.txt AC 16 ms 2984 KiB
test_12.txt AC 25 ms 2996 KiB
test_13.txt AC 22 ms 2996 KiB
test_14.txt AC 28 ms 2972 KiB
test_15.txt AC 38 ms 2976 KiB