1

(3 ответов, оставленных в Algo)

We can find it using BFS.
when we reach each node we must increment its degree by one..
if we see that there some nodes with degree >=2 then graph is not tree.

2

(3 ответов, оставленных в Problems)

it hasn't got so long code:

       double len=floor(n*log10(n))+1;

       double ost=n*log10(n)+1.0-len;

       unsigned long long result=(unsigned long long)(pow(10.0,ost));