結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2025-07-28 13:59:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 74 ms / 1,000 ms |
コード長 | 385 bytes |
コンパイル時間 | 2,645 ms |
コンパイル使用メモリ | 273,372 KB |
実行使用メモリ | 13,596 KB |
最終ジャッジ日時 | 2025-07-28 13:59:09 |
合計ジャッジ時間 | 4,116 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%lld %lld",&n,&l); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n,l,ans=0; bool prm[10000009]; signed main() { scanf("%lld %lld",&n,&l); memset(prm,1,sizeof(prm)); prm[1]=false; for(int i=2; i<=l; i++) { if(!prm[i]) continue; for(int j=i*2; j<=l; j+=i) prm[j]=false; ll fst=l-i*(n-1)+1; if(fst<=0) break; ans+=fst; } printf("%lld\n",ans); return 0; }