結果
| 問題 | No.3388 Sum of Function |
| コンテスト | |
| ユーザー |
クロさん
|
| 提出日時 | 2025-12-06 22:30:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 927 bytes |
| 記録 | |
| コンパイル時間 | 4,551 ms |
| コンパイル使用メモリ | 253,712 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-06 22:30:21 |
| 合計ジャッジ時間 | 5,834 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
static const double pi = 3.141592653589793;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ll imod = 998244353;
using mint = modint998244353;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
ll P(ll x, ll n) {
ll ret = 1;
while (n > 0) {
if (n & 1) ret *= x;
x *= x;
n >>= 1;
}
return ret;
}
void seek(bool f){
cout << (f ? "Yes" : "No") << endl;
}
int main(){
ll C = 101;
vector<bool> prime(C, true);
prime[0] = prime[1] = false;
for(int i = 2; i < C; i++){
if(prime[i]){
for(int j = 2; i * j < C; j++){
prime[i * j] = false;
}
}
}
int ans = 0;
int A, B;
cin >> A >> B;
for(int i = A; i <= B; i++){
if(prime[i]){
ans += P(i, 3) - P(i, 2) + P(i, 1) + 1;
}
}
cout << ans << endl;
}
クロさん