結果

問題 No.3388 Sum of Function
コンテスト
ユーザー vjudge1
提出日時 2026-02-09 23:54:57
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,089 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,998 ms
コンパイル使用メモリ 224,092 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-02-09 23:55:10
合計ジャッジ時間 4,966 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:36:9: 警告: ‘INT_MAX’ redefined
   36 | #define INT_MAX LLONG_MAX
      |         ^~~~~~~
次のファイルから読み込み:  /usr/local/gcc-15/include/c++/15.2.0/climits:47,
         次から読み込み:  /usr/local/gcc-15/include/c++/15.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:37,
         次から読み込み:  main.cpp:10:
/usr/local/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.2.0/include/limits.h:120:9: 備考: ここが以前の宣言がある位置です
  120 | #define INT_MAX __INT_MAX__
      |         ^~~~~~~

ソースコード

diff #
raw source code

/*   Bismillah
*    Author: Akhyar Ahmed Turk
*    Created: 2026-02-08 20:56 (GMT+5)

*    brain["Motivation"].insert("Ya to win hy ya learn");

*    Those who can't remember the past are condemned to repeat it.
*                                                 -Dynamic Programming.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// use when u need indexing in sets like (when you need lower upper bound while frequently updating set) 
// idx.order_of_key(value) for nums<value idx.order_of_key(value+1) for nums<=value
// idx.find_by_order(n); to get the nth value by order
#define int long long
#define ld long double
#define yesno(b) cout << ((b) ? "YES" : "NO") << "\n";
#define pii pair<int, int>
#define pb push_back
#define f first
#define ss second
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define mod2 998244353
const int inf = 1e17 + 1;
#define INT_MAX LLONG_MAX
#define nl "\n"

#define forn(i, a, b) for (int i = a; i < b; i++)
#define forr(i, a, b) for (int i = a; i >= b; i--)
#define input(vec, n) for(int z = 0; z < (n); z++) cin >> vec[z];

void solve() {
    // prime sieve 
    int N=200;
    vector<bool> is_prime(N + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= N; i++){
        if (is_prime[i]){
            for (int j = i * i; j <= N; j += i){
                is_prime[j] = false;
            }
        }
    }
    int a,b; cin>>a>>b;
    int res=0;
    while(a<=b){
        if(is_prime[a]) res+=a*a*a-a*a+a+1;
        a++;
    }
    cout<<res<<endl;
}

int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
    int t=1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
0