結果
| 問題 | No.3388 Sum of Function |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-10 02:31:31 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 559 bytes |
| 記録 | |
| コンパイル時間 | 3,147 ms |
| コンパイル使用メモリ | 333,880 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-02-10 02:31:38 |
| 合計ジャッジ時間 | 4,427 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// Function to check if a number is prime
bool isPrime(int n) {
if (n < 2) return false;
for (int i = 2; i*i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
// Function f(x) = x^3 - x^2 + x + 1
int f(int x) {
return x*x*x - x*x + x + 1;
}
int main() {
int A, B;
cin >> A >> B;
int sum = 0;
for (int x = A; x <= B; x++) {
if (isPrime(x)) {
sum += f(x);
}
}
cout << sum << "\n"; // End with a newline
return 0;
}
vjudge1