結果
| 問題 | No.826 連絡網 |
| コンテスト | |
| ユーザー |
kotamanegi
|
| 提出日時 | 2019-05-03 21:40:54 |
| 言語 | C++17(clang) (17.0.6 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,159 bytes |
| 記録 | |
| コンパイル時間 | 1,299 ms |
| コンパイル使用メモリ | 150,688 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-11-30 14:04:48 |
| 合計ジャッジ時間 | 22,813 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 TLE * 4 |
ソースコード
#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] = {};
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();
int nya = next;
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;
}
}
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;
}
kotamanegi