結果
| 問題 | 
                            No.826 連絡網
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ゆるく
                         | 
                    
| 提出日時 | 2019-05-05 04:02:56 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 958 bytes | 
| コンパイル時間 | 279 ms | 
| コンパイル使用メモリ | 12,928 KB | 
| 実行使用メモリ | 30,108 KB | 
| 最終ジャッジ日時 | 2024-06-23 18:41:15 | 
| 合計ジャッジ時間 | 5,095 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 10 TLE * 1 -- * 19 | 
ソースコード
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
def find(x):
    if node[x] < 0:
        return x
    else:
        node[x] = find(node[x])
        return node[x]
def unite(x, y):
    x = find(x)
    y = find(y)
    if x != y:
        if rank[x] > rank[y]:
            node[x] += node[y]
            node[y] = x
        else:
            node[y] += node[x]
            node[x] = y
            if rank[x] == rank[y]:
                rank[y] += 1
def is_same(x, y):
    return find(x) == find(y)
def size(x):
    return -node[find(x)]
n, p = map(int, input().split())
node = [-1 for i in range(n + 1)]
rank = [0 for _ in range(n + 1)]
for i in range(2,n + 1):
    for j in range(i, n + 1, i):
        if i + j > n:
            break
        unite(i, i + j)
print(size(find(p)))
            
            
            
        
            
ゆるく