Submission #1513698


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
typedef int64_t ll;
typedef std::vector<ll> vll;
using namespace std;
struct Math {
    
    // エラトステネスの篩、O(n log2 log2 n)
    template<typename T> std::map<T, bool> sieve(T n) {
        std::map<T, bool> res;
        res[0] = false;
        res[1] = false;
        for (size_t i = 2; i <= (size_t)n; i++) {
            res[i] = true;
        }
        // size_t p = 0;
        for (size_t i = 2; i <= (size_t)n; i++) {
            if (res[i]) {
                // prime[p++] = i;
                for (size_t j = 2 * i; j <= (size_t)n; j += i) {
                    res[j] = false;
                }
            }
        }
        return res;
    }
    
};
struct Solution {
    Math m;
    void solve(std::istream& in, std::ostream& out) {
        auto p = m.sieve(200000);
        
        int j = 0;
        vll ans(100, 1);
        rep(i, 200001) {
            if (!p[i]) continue;
            if (ans[j] * i <= 1000000000) {
                ans[j] *= i;
            }
            else {
                j++;
                if (j == 100) break;
                ans[j] *= i;
            }
        }
        rep(i, 100) {
            out << ans[i] << std::endl;
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}

Submission Info

Submission Time
Task A - 約数をたくさんつくろう!
User masakt
Language C++14 (GCC 5.4.1)
Score 1097
Code Size 1671 Byte
Status AC
Exec Time 168 ms
Memory 9600 KB

Judge Result

Set Name test_01
Score / Max Score 1097 / 100000
Status
AC × 1
Set Name Test Cases
test_01 noinput.txt
Case Name Status Exec Time Memory
noinput.txt AC 168 ms 9600 KB