結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2016-08-07 21:23:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 405 bytes |
コンパイル時間 | 941 ms |
コンパイル使用メモリ | 57,076 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-07 09:39:06 |
合計ジャッジ時間 | 6,013 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 29 TLE * 2 |
ソースコード
#include<iostream> #include<vector> using namespace std; //素数判定 O(√n) bool is_Prime(int n) { for (int i = 2; i*i <= n; i++) { if (n%i == 0) return false; } return n != 1; } int main() { int N, L; cin >> N >> L; long long ans = 0; for (int i = 1; i*(N-1) <= L; i++) { if (is_Prime(i) && i * (N - 1) <= L) ans += L - i*(N - 1) + 1; } cout << ans << endl; return 0; }