結果

問題 No.3388 Sum of Function
コンテスト
ユーザー vjudge1
提出日時 2026-02-10 01:52:26
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,071 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,420 ms
コンパイル使用メモリ 333,628 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-10 01:52:31
合計ジャッジ時間 4,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define int long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define vpis vector<pair<int, string>>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<int, int>
#define vvpii vector<vector<pair<int, int>>>
#define rep(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()
#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define MOD 1000000007
#define endl "\n"

bool isPrime(int n) {
    if(n <= 1) return false;
    if(n == 2) return true;
    if(n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if(n % i == 0) return false;
    }
    return true;
}

signed main() {
    fastio;
    // int t;
    // cin >> t;
    // while(t--) {
        
    // }
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, a, b + 1) {
        if(isPrime(i)) ans += (i * i * i) - (i * i) + i + 1;
    }
    cout << ans << endl;
}
0