結果

問題 No.3388 Sum of Function
コンテスト
ユーザー GOTKAKO
提出日時 2025-11-29 04:39:58
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 503 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,027 ms
コンパイル使用メモリ 198,328 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-29 04:40:02
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int Need = 100;
    vector<bool> prime(Need+1,true);
    prime.at(0) = false; prime.at(1) = false;
    for(int i=2; i*i<=Need; i++){
        if(!prime.at(i)) continue;
        for(int k=i*i; k<=Need; k+=i) prime.at(k) = false;
    }
    int A,B; cin >> A >> B;
    int answer = 0;
    for(int i=A; i<=B; i++) if(prime.at(i)) answer += i*i*i-i*i+i+1;
    cout << answer << endl;
}
0