結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2016-10-20 21:15:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 1,000 ms |
| コード長 | 1,041 bytes |
| コンパイル時間 | 2,655 ms |
| コンパイル使用メモリ | 161,300 KB |
| 実行使用メモリ | 17,288 KB |
| 最終ジャッジ日時 | 2024-12-16 01:40:39 |
| 合計ジャッジ時間 | 6,839 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
using ll = long long;
using P = std::tuple<int,int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
bool isNotPrime[10000000];
vector<int> primes;
int main(){
//*
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
/*/
/*/
primes.emplace_back(2);
for(int i=4;i<10000000;i+=2){
isNotPrime[i] = true;
}
for(int i=3;i<10000000;i+=2){
if(!isNotPrime[i]){
primes.emplace_back(i);
for(int j=i*2;j<10000000;j+=i){
isNotPrime[j] = true;
}
}
}
int N, L;
std::cin >> N >> L;
ll res = 0ll;
for(int p : primes){
int a = L / p + 1, b = L % p + 1;
if(a >= N){
res += 1ll * b * (a - N + 1);
res += 1ll * (p - b) * (a - N);
}
}
std::cout << res << std::endl;
}
tottoripaper