結果

問題 No.106 素数が嫌い!2
ユーザー SSRS
提出日時 2020-09-03 07:28:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 880 ms
コンパイル使用メモリ 71,428 KB
最終ジャッジ日時 2025-01-14 04:04:34
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 3 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> f(N + 1, -1);
	f[1] = 0;
	int ans = 0;
	for (int i = 2; i <= N; i++){
		for (int j = i; j <= N; j += i){
			if (f[j] == -1){
				int x = j;
				while (x % i == 0){
					x /= i;
				}
				f[j] = f[x] + 1;
				if (f[j] >= K){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}
0