You are given an undirected graph withnodes (numbered through ). For each valid , the -th node has a weight . Also, for each pair of nodes and , there is an edge connecting these nodes if .
Find the number of connected components in this graph.
For each test case, print a single line containing one integer — the number of connected components in the graph.
Example case 1: Forand , we have , therefore there are no edges in the graph and there are two connected components.
Example case 2: Forand , we have , therefore there is an edge between and , the graph is connected, so there is only one connected component.
CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM
You are given an undirected graph with NN nodes (numbered 11 through NN). For each valid ii, the ii-th node has a weight WiWi. Also, for each pair of nodes ii and jj, there is an edge connecting these nodes if j−i≠Wj−Wij−i≠Wj−Wi. Find the number of connected components in this graph.