Composius' Wrath
시간 제한1초메모리 제한2048 MB
가중치가 있는 연결 무향 그래프에서 간선 길이가 소수인 간선의 수가 최대가 되는 신장 트리를 찾아, 소수 길이 간선 수와 그렇지 않은 간선 수를 출력한다.
문제
After many years of praising their god Primos, the very wealthy land of Primozia had a large number of cities that were connected by many roads, enabling traders to travel from every city to every other city in very little time. This caused the god Composius to be very displeased, because he does not like to see such wealth in a country that idolizes prime numbers. Therefore he cast his wrath upon the land of Primozia and destructed all their trade routes by the force of an incredible tsunami.
After hearing about this, the first priority of the pharaoh of Primozia was to rebuild the network of roads such that all trading can continue. However, in order to connect every city with every other city as soon as possible, the pharaoh orders to rebuild the road network with as few roads as possible, such that a path exists from every city to every other city. Additionally, he wants to rebuild as many roads with prime lengths as possible, because prime numbers are sacred in the land of Primozia.
입력
On the first line two integers, the number of cities and the number of roads . On the next lines, three integers , and are given, with and the endpoints of a road and the length of that road.
출력
One line with two integers and . With the number of roads with prime length and the number of roads with non-prime length.