Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a tree T of size N . You are given a 2 D array E of size M , where there exists

You are given a tree T of size N. You are given a 2D array E of size M, where there exists an edge between E[i][0] and E[i][1] for all 1iM.
You are also given an array A of size N, where the node U has a value .
A path P is called a good path if the greatest common divisor(GCD) of all of the values present on the path P is equal to 1. Two paths P1,P2 are considered the same if they have the same number of nodes and each node x of path P1 belongs to P2.
Find the total number of possible good paths present in T.
Note:
The path (U,U) is valid for all nodes U.
Input Format
The first line contains an integer, N, denoting the number of elements in A.
The next line contains an integer, M, denoting the number of rows in E.
The next line contains an integer, two, denoting the number of columns in E.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago