結果
問題 | No.826 連絡網 |
ユーザー | kotamanegi |
提出日時 | 2019-05-03 21:53:53 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 867 ms / 2,000 ms |
コード長 | 2,564 bytes |
コンパイル時間 | 1,280 ms |
コンパイル使用メモリ | 99,376 KB |
実行使用メモリ | 35,300 KB |
最終ジャッジ日時 | 2023-08-15 18:16:46 |
合計ジャッジ時間 | 8,964 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,688 KB |
testcase_01 | AC | 2 ms
7,488 KB |
testcase_02 | AC | 2 ms
7,440 KB |
testcase_03 | AC | 3 ms
7,824 KB |
testcase_04 | AC | 3 ms
7,600 KB |
testcase_05 | AC | 3 ms
7,764 KB |
testcase_06 | AC | 2 ms
7,476 KB |
testcase_07 | AC | 3 ms
7,604 KB |
testcase_08 | AC | 3 ms
7,612 KB |
testcase_09 | AC | 3 ms
7,516 KB |
testcase_10 | AC | 2 ms
7,580 KB |
testcase_11 | AC | 2 ms
7,680 KB |
testcase_12 | AC | 558 ms
29,068 KB |
testcase_13 | AC | 156 ms
14,244 KB |
testcase_14 | AC | 371 ms
23,272 KB |
testcase_15 | AC | 23 ms
10,576 KB |
testcase_16 | AC | 210 ms
18,256 KB |
testcase_17 | AC | 158 ms
14,344 KB |
testcase_18 | AC | 111 ms
13,692 KB |
testcase_19 | AC | 669 ms
29,552 KB |
testcase_20 | AC | 660 ms
29,432 KB |
testcase_21 | AC | 5 ms
7,632 KB |
testcase_22 | AC | 157 ms
14,292 KB |
testcase_23 | AC | 221 ms
17,348 KB |
testcase_24 | AC | 73 ms
13,500 KB |
testcase_25 | AC | 860 ms
35,300 KB |
testcase_26 | AC | 95 ms
13,600 KB |
testcase_27 | AC | 580 ms
28,844 KB |
testcase_28 | AC | 397 ms
23,604 KB |
testcase_29 | AC | 152 ms
14,268 KB |
testcase_30 | AC | 867 ms
35,044 KB |
testcase_31 | AC | 200 ms
17,232 KB |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include <random> #include <map> #include <fstream> #include <iomanip> #include <time.h> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <assert.h> #include <complex> using namespace std; #define eps 0.000001 #define LONG_INF 10000000000000 #define GOLD 1.61803398874989484820458 #define seg_size 65536*4 #define REP(i,n) for(long long i = 0;i < n;++i) unsigned long xor128() { static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123; unsigned long t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } long long visited[2000000] = {}; long long nekoi[2000000] = {}; long long heas[2000000] = {}; int sosuu[2000000] = {}; int main() { int n, k; cin >> n >> k; if (k == 1) { cout << 1 << endl; return 0; } visited[k] = 1; heas[0] = k; int now_itr = 0; int max_itr = 1; vector<int> sosuu_list; for (int i = 2; i <= n; ++i) { int ok = 1; for (int q = 2; q <= sqrt(i); ++q) { if (i % q == 0) { ok = 0; break; } } if (ok == 1) { sosuu_list.push_back(i); sosuu[i] = 1; } } while (now_itr < max_itr) { int next = heas[now_itr]; now_itr++; int nya = next; if (sosuu[nya] == 1&&nekoi[nya] == 0) { nekoi[nya] = 1; for (int j = 1; j * nya <= n; ++j) { if (visited[j * nya] == 0) { visited[j * nya] = 1; heas[max_itr] = (j * nya); max_itr++; } nekoi[j * nya] = 1; } } for (int tea = 0;sosuu_list[tea] <= sqrt(next); ++tea) { int i = sosuu_list[tea]; if (next % i == 0) { int nya = i; if (sosuu[nya] == 1&&nekoi[nya] == 0) { nekoi[nya] = 1; for (int j = 1; j * nya <= n; ++j) { if (visited[j * nya] == 0) { visited[j * nya] = 1; heas[max_itr] = (j * nya); max_itr++; } nekoi[j * nya] = 1; } } nya = next / i; if (sosuu[nya] == 1&&nekoi[nya] == 0) { nekoi[nya] = 1; for (int j = 1; j * nya <= n; ++j) { if (visited[j * nya] == 0) { visited[j * nya] = 1; heas[max_itr] = (j * nya); max_itr++; } nekoi[j * nya] = 1; } } } } } cout << max_itr << endl; return 0; }