結果
問題 | No.106 素数が嫌い!2 |
ユーザー |
![]() |
提出日時 | 2015-08-04 23:23:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 71,580 KB |
実行使用メモリ | 13,548 KB |
最終ジャッジ日時 | 2024-07-18 01:20:54 |
合計ジャッジ時間 | 1,292 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d%d",&n,&k); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <cstring> typedef long long ll; using namespace std; #define mod 1000000009 #define INF 10000000 #define LLINF 2000000000000000000LL #define SIZE 101 const int MAX_P = 2000000; bool prime[MAX_P+1]; void primen(void){ for(int i=2;i<=MAX_P;i++) prime[i]=true; for(int i=2;i*i<=MAX_P;i++) if(prime[i]) for(int j=i;i*j<=MAX_P;j++) prime[i*j]=false; } int n,k,num[2000001]={0},ans=0; int main(){ scanf("%d%d",&n,&k); primen(); for(int i=2;i<=n;i++){ if(prime[i]){ for(int j=i;j<=n;j+=i){ num[j]++; } } } for(int i=2;i<=n;i++){ if(num[i]>=k){ ans++; } } printf("%d\n",ans); return 0; }