Submission #3704565

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#include <vector>
using namespace std;

vector<int> primes;
vector<int> smallest_prime_factor;

int sieve(int nmax){
    primes.clear();
    smallest_prime_factor.assign(nmax+1, 0);

    for (int n=2; n<=nmax; ++n) {
        if (!smallest_prime_factor[n]) {
            primes.push_back(n);
            for (int kn=n; kn<=nmax; kn+=n) {
                if (!smallest_prime_factor[kn]) {
                    smallest_prime_factor[kn] = n;
                }
            }
        }
    }
    return primes.size();
}

vector<int> factorize(int x) {
    vector<int> prime_factors;
    while (x > 1) {
        int s = smallest_prime_factor[x];
        if (!s) break;
        prime_factors.push_back(s);
        x /= s;
    }
    return prime_factors;
}



int f(vi& m, vi a) {
    sort(ALL(a));
    int L=m.size();
    if (L < a.size()) return 0;
    int cnt=0;
    switch (a.size()) {
        case 1:
            cnt = (m[0] >= a[0]) ? 1 : 0;
            break;
        case 2:
            repC2(i,j,L){
                do {
                    if (m[i] >= a[0] && m[j] >= a[1]) ++cnt;
                } while (next_permutation(ALL(a)));
            }
            break;
        case 3:
            for (int i=0; i<L-2; ++i){
                for (int j=i+1; j<L-1; ++j) {
                    for (int k=j+1; k<L; ++k) {
                        do {
                            if (m[i] >= a[0] && m[j] >= a[1] && m[k] >= a[2]) ++cnt;
                        } while (next_permutation(ALL(a)));
                    }
                }
            }
            break;
        default:
            break;
    }
    return cnt;
}

ll solve(int N) {
    map<int,int> m;
    for (int n=1; n<=N; ++n){
        vi fs = factorize(n);
        for (int x: fs) {
            m[x]++;
        }
    }
    vi m2;
    for (ii p: m){
        if (p.second >= 2) m2.pb(p.second);
    }
    return f(m2,vi{2,4,4}) + f(m2,vi{2,24}) + f(m2,vi{4,14}) + f(m2,vi{74});
}

int main() {
    sieve(100);
    int N; cin >> N;
    cout << solve(N) << endl;
    return 0;
}

Submission Info

Submission Time
Task D - 756
User naoya_t
Language C++14 (GCC 5.4.1)
Score 400
Code Size 3683 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 400 / 400 a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20
Case Name Status Exec Time Memory
a01 1 ms 256 KB
a02 1 ms 256 KB
a03 1 ms 256 KB
b04 1 ms 256 KB
b05 1 ms 256 KB
b06 1 ms 256 KB
b07 1 ms 256 KB
b08 1 ms 256 KB
b09 1 ms 256 KB
b10 1 ms 256 KB
b11 1 ms 256 KB
b12 1 ms 256 KB
b13 1 ms 256 KB
b14 1 ms 256 KB
b15 1 ms 256 KB
b16 1 ms 256 KB
b17 1 ms 256 KB
b18 1 ms 256 KB
b19 1 ms 256 KB
b20 1 ms 256 KB