結果

問題 No.106 素数が嫌い!2
ユーザー SSRSSSRS
提出日時 2020-09-03 07:28:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 74,124 KB
実行使用メモリ 10,944 KB
最終ジャッジ日時 2023-08-14 17:54:18
合計ジャッジ時間 2,189 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 105 ms
10,820 KB
testcase_08 WA -
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 107 ms
10,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

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