結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2025-07-27 13:32:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 147 ms / 1,000 ms |
コード長 | 454 bytes |
コンパイル時間 | 1,968 ms |
コンパイル使用メモリ | 194,204 KB |
実行使用メモリ | 10,792 KB |
最終ジャッジ日時 | 2025-07-27 13:32:31 |
合計ジャッジ時間 | 4,873 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define int ll const int N=2e6+7; int n,m,res=0,pr[N],tot=0; bitset<10000007>vis; signed main(){ cin>>n>>m; vis[0]=vis[1]=1; for(int i=2;i<=m;i++){ if(!vis[i])pr[++tot]=i; for(int j=1;j<=tot&&pr[j]*i<=m;j++){ vis[pr[j]*i]=1; if(i%pr[j]==0)break; } } for(int i=1;i<=tot;i++){ if(m-pr[i]*(n-1)<0)continue; res+=max(0ll,m-pr[i]*(n-1))+1; } cout<<res<<"\n"; }