結果

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

ソースコード

diff #
raw source code

// Online compiler C++
#include<bits/stdc++.h>
using namespace std ;
#define nl "\n"
#define int long long
using vi = vector<int> ;

void solve() {
    int a , b ;
    cin >> a >> b ;
    
    int res = 0 ;
    for( int i = a ; i <= b ; i++ ) {
        int temp = i ;
        if( temp != 2 && temp % 2 == 0 ) continue ;
        else if( temp == 1 ) continue ;
        
        bool f = true ;
        for( int j = 2 ; j * j <= i ; j++ ) {
            if( i % j == 0 ) {
                f = false ;
                break ;
            }
        }
        
        if( f ) res += pow( i , 3 ) - pow( i , 2 ) + i + 1 ;
    }
    cout << res << nl ;
}
signed main() {
    int t = 1 ;
    // cin >> t ;
    while( t-- ) {
        solve() ;
    }
    return 0 ;
} 
0