結果

問題 No.3388 Sum of Function
コンテスト
ユーザー ルビサファせだい
提出日時 2025-11-28 21:38:51
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 3,043 ms
コンパイル使用メモリ 279,908 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-28 21:39:04
合計ジャッジ時間 3,803 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#include <atcoder/fenwicktree.hpp>
#include <atcoder/segtree.hpp>
#include <atcoder/modint.hpp>
#include <atcoder/dsu.hpp>
#include <atcoder/lazysegtree.hpp>

using namespace atcoder;
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<>>;
ll ll_min = numeric_limits<ll>::min();
ll ll_max = numeric_limits<ll>::max();
ll ALPHABET_N = 26;
// using mint = modint998244353;
// using mint = modint1000000007;
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define rep_(i, k, n) for (ll i = (ll)k; i < (ll)n; i++)
#define all(a) a.begin(), a.end()

int main()
{
	ll a, b;
	cin >> a >> b;
	auto isPrime = [](ll x)
	{
		if (x == 1)
			return false;
		for (ll i = 2; i * i <= x; i++)
		{
			if (x % i == 0)
				return false;
		}
		return true;
	};
	auto f = [](ll x)
	{ return x * x * x - x * x + x + 1; };
	ll ans = 0;
	for (ll i = a; i <= b; i++)
		if (isPrime(i))
			ans += f(i);
	cout << ans << endl;
	return 0;
}
0