結果

問題 No.1059 素敵な集合
ユーザー veqccveqcc
提出日時 2020-05-22 23:18:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 885 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 105,556 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-15 18:45:29
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main() {
    int l, r;
    cin >> l >> r;

    vector<int> primes;
    for (int i = l; i <= r; i++) {
        if (is_prime(i)) {
            primes.push_back(i);
        }
    }

    int sum = 0;
    for (int i = l + 1; i <= r; i++) {
        int mn = 1;
        for (int x : primes) {
            if (x >= i) break;
            mn = min(mn, i % x);
        }
        sum += mn;
    }

    cout << sum << endl;
    return 0;
}
0