結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2016-08-05 22:41:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 222 ms / 1,000 ms |
コード長 | 943 bytes |
コンパイル時間 | 983 ms |
コンパイル使用メモリ | 85,432 KB |
実行使用メモリ | 81,536 KB |
最終ジャッジ日時 | 2024-12-15 20:28:34 |
合計ジャッジ時間 | 3,392 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <iomanip> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) long long m[100000000] = {}; int main() { int n, l; cin >> n >> l; m[1] = true; for (int i = 2;i < sqrt(l) + 1;++i) { if (m[i] == false) { for (int q = 2;i*q < l + 1;++q) { m[i*q] = true; } } } n--; long long ans = 0; for (long long i = 2;i >= 0;++i) { if (m[i] == false) { long long hoge = n*i; if (l - hoge >= 0) { ans += l - hoge + 1; } else { cout << ans << endl; return 0; } } } }