結果

問題 No.826 連絡網
ユーザー chocoruskchocorusk
提出日時 2019-05-03 21:38:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 1,632 ms
コンパイル使用メモリ 94,664 KB
実行使用メモリ 15,224 KB
最終ジャッジ日時 2023-08-15 18:10:53
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,536 KB
testcase_01 AC 2 ms
7,524 KB
testcase_02 AC 1 ms
7,520 KB
testcase_03 AC 2 ms
7,536 KB
testcase_04 AC 2 ms
7,488 KB
testcase_05 AC 1 ms
7,436 KB
testcase_06 AC 2 ms
7,512 KB
testcase_07 AC 2 ms
7,460 KB
testcase_08 AC 2 ms
7,444 KB
testcase_09 AC 2 ms
7,492 KB
testcase_10 AC 1 ms
7,432 KB
testcase_11 AC 2 ms
7,548 KB
testcase_12 AC 70 ms
14,044 KB
testcase_13 AC 23 ms
12,776 KB
testcase_14 AC 50 ms
13,604 KB
testcase_15 AC 6 ms
9,792 KB
testcase_16 AC 31 ms
12,956 KB
testcase_17 AC 23 ms
12,744 KB
testcase_18 AC 18 ms
12,496 KB
testcase_19 AC 85 ms
14,544 KB
testcase_20 AC 84 ms
14,388 KB
testcase_21 AC 2 ms
7,500 KB
testcase_22 AC 24 ms
12,848 KB
testcase_23 AC 33 ms
13,028 KB
testcase_24 AC 14 ms
12,240 KB
testcase_25 AC 100 ms
15,224 KB
testcase_26 AC 15 ms
12,320 KB
testcase_27 AC 74 ms
14,152 KB
testcase_28 AC 55 ms
13,572 KB
testcase_29 AC 24 ms
12,748 KB
testcase_30 AC 113 ms
15,116 KB
testcase_31 AC 32 ms
13,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int sz[1000010];
int par[1000010];
int rk[1000010];
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
        rk[i]=0;
        sz[i]=1;
	}
}
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
        sz[y]+=sz[x];
	}else{
		par[y]=x;
        sz[x]+=sz[y];
		if(rk[x]==rk[y]) rk[x]++;
	}
}
int main()
{
    int n, p; cin>>n>>p;
    init(n+1);
    for(int i=2; i<=n; i++){
        for(int j=i; j+i<=n; j+=i){
            unite(j, j+i);
        }
    }
    cout<<sz[find(p)]<<endl;
    return 0;
}
0