結果

問題 No.106 素数が嫌い!2
ユーザー 👑 kmjpkmjp
提出日時 2014-12-18 23:22:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 1,340 ms
コンパイル使用メモリ 144,744 KB
実行使用メモリ 12,156 KB
最終ジャッジ日時 2023-09-02 18:49:29
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
11,912 KB
testcase_01 AC 16 ms
11,924 KB
testcase_02 AC 18 ms
11,912 KB
testcase_03 AC 17 ms
11,916 KB
testcase_04 AC 33 ms
12,096 KB
testcase_05 AC 35 ms
11,944 KB
testcase_06 AC 35 ms
12,016 KB
testcase_07 AC 35 ms
11,928 KB
testcase_08 AC 31 ms
11,996 KB
testcase_09 AC 32 ms
11,920 KB
testcase_10 AC 38 ms
11,924 KB
testcase_11 AC 34 ms
11,916 KB
testcase_12 AC 36 ms
11,924 KB
testcase_13 AC 13 ms
12,100 KB
testcase_14 AC 14 ms
12,156 KB
testcase_15 AC 25 ms
12,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,N;
const int prime_max = 2200000;
int divp[prime_max];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	int ret=0;
	for(int i=2;i<=N;i++) {
		if(divp[i]==0) {
			for(int j=i;j<prime_max;j+=i) divp[j]++;
		}
		if(divp[i]>=K) ret++;
	}
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0