結果
問題 | No.826 連絡網 |
ユーザー | kotamanegi |
提出日時 | 2019-05-03 21:37:16 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,951 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 100,556 KB |
実行使用メモリ | 27,488 KB |
最終ジャッジ日時 | 2023-08-30 05:59:35 |
合計ジャッジ時間 | 16,033 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,556 KB |
testcase_01 | AC | 2 ms
5,604 KB |
testcase_02 | AC | 2 ms
5,416 KB |
testcase_03 | WA | - |
testcase_04 | AC | 5 ms
5,508 KB |
testcase_05 | AC | 3 ms
5,444 KB |
testcase_06 | AC | 3 ms
5,452 KB |
testcase_07 | AC | 4 ms
5,788 KB |
testcase_08 | AC | 3 ms
5,464 KB |
testcase_09 | AC | 5 ms
5,800 KB |
testcase_10 | AC | 2 ms
5,440 KB |
testcase_11 | AC | 4 ms
5,616 KB |
testcase_12 | AC | 1,877 ms
18,752 KB |
testcase_13 | AC | 475 ms
11,112 KB |
testcase_14 | AC | 1,209 ms
15,552 KB |
testcase_15 | AC | 53 ms
6,212 KB |
testcase_16 | AC | 671 ms
11,460 KB |
testcase_17 | AC | 479 ms
11,140 KB |
testcase_18 | AC | 330 ms
8,720 KB |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | AC | 6 ms
5,608 KB |
testcase_22 | AC | 487 ms
11,216 KB |
testcase_23 | AC | 706 ms
12,632 KB |
testcase_24 | AC | 208 ms
7,876 KB |
testcase_25 | TLE | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
#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> #include <omp.h> 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] = {}; int main() { int n, k; cin >> n >> k; if (k == 1) { cout << 1 << endl; return 0; } visited[k] = 1; queue<int> now; now.push(k); while (now.empty() == false) { int next = now.front(); now.pop(); for (int i = 2; i <= sqrt(next); ++i) { if (next % i == 0) { int nya = i; if (nekoi[nya] == 0) { nekoi[nya] = 1; for (int j = 1; j * nya <= n; ++j) { if (visited[j * nya] == 0) { visited[j * nya] = 1; now.push(j * nya); } nekoi[j * nya] = 1; } } nya = next / i; if (nekoi[nya] == 0) { nekoi[nya] = 1; for (int j = 1; j * nya <= n; ++j) { if (visited[j * nya] == 0) { visited[j * nya] = 1; now.push(j * nya); } nekoi[j * nya] = 1; } } } } } long long ans = 0; for (int i = 1; i <= n; ++i) { ans += visited[i]; } cout << ans << endl; return 0; }